Generate classes

@return void
764059
protected function generateClasses()
    {
        $this->display(' * Generate classes files for Data & Mapper ' . PHP_EOL);

        $this->display('  > generate [  0%]: Data File      ' . "\r");
        $this->generateDataFiles();

        $this->display('  > generate [ 50%]: Data File      ' . "\r");
        $this->generateMapperFiles();

        $this->display('  > generate [100%]: done !    ' . "\r");
        $this->display(PHP_EOL . PHP_EOL);
    }
1144979
protected function classes()
    {
        list($items, $pattern) = array(array(), '/\\.[^.\\s]{3,4}$/');

        $files = glob($this->commands . '/*.php');

        $path = strlen($this->commands . DIRECTORY_SEPARATOR);

        foreach ((array) $files as $file) {
            $substring = substr($file, $path);

            $class = preg_replace($pattern, '', $substring);

            $class = $this->namespace . '\\' . $class;

            $reflection = new \ReflectionClass($class);

            $reflection->isAbstract() || $items[] = $class;
        }

        return $items;
    }
1105091
public function Generate ()
	{
		
		// If there is a table but no namespace or name
		
		if ($this->get ('table') && (!$this->get ('namespace') || !$this->get ('name')))
		{
			
			// Get namespace and name details from the table name
			
			list ($namespace, $class)	= $this->parser->convertToNamespaceAndClass ($this->get ('table'));
			
			// Set namespace and name
			
			if (!$this->get ('namespace'))
			{
				$this->set ('namespace', $namespace);
			}
			
			if (!$this->get ('name'))
			{
				$this->set ('name', $class);
			}
			
		}
		
		// Start script
		
		$this->addLine ('<?php');
		$this->addLine ();
		
		// Add class comment
		
		$comment	= 
			($this->get ('description')?	$this->get ('description') . "\n\n" : NULL) . 
			($this->get ('author')?			$this->tabVals ('@author',		$this->get ('author'), 4, '') . "\n" : NULL) . 
			($this->get ('email')?			$this->tabVals ('@email',		$this->get ('email'), 4, '') . "\n" : NULL) . 
			($this->get ('link')?			$this->tabVals ('@link',		$this->get ('link'), 4, '') . "\n" : NULL) . 
			($this->get ('copyright')?		$this->tabVals ('@copyright ',	$this->get ('copyright'), 4, '') . "\n" : NULL) . 
			($this->get ('date_created')?	$this->tabVals ('@datecreated',	$this->get ('date_created'), 5, '') . "\n" : NULL);
		
		if (substr ($comment, -1) == "\n")
		{
			$comment	= substr ($comment, 0, -1);
		}
		
		$this->phpdocComment ($comment);
		$this->addLine ();
		$this->phpdocComment ($this->generateProperties ());
		$this->addLine ();
		
		// Define namespace
		
		$this->lineComment ('Define namespace');
		$this->addLine ();
		$this->addLine ('namespace ' . $this->get ('namespace') . ';');
		$this->addLine ();
		
		// Start class
		
		$this->lineComment ('Start ' . $this->get ('name') . ' Class');
		$this->addLine ();
		$this->addLine ('class ' . $this->get ('name') . ' extends ' . $this->get ('extends'));
		$this->addLine ('{');
		$this->tabUp ();
		$this->addLine ();
		
		// Database table

		if ($this->get ('table'))
		{
			$this->phpdocComment ("Database table\n@var string");
			$this->addLine ();
			$this->addLine ('public static $dbTable	= \'' . $this->get ('table') . '\';');
			$this->addLine ();
		}
		
		// Get primary key
		
		$pk	= $this->getPk ();
		
		// If there is a primary key which is different to the default
		
		if (is_array ($pk) && $pk['Field'] !== self::$pk)
		{
			
			// Set it
			
			$this->phpdocComment ("Primary key field\n@var string");
			$this->addLine ();
			$this->addLine ('public static $pk	= \'' . $pk['Field'] . '\';');
			$this->addLine ();
			
		}
		
		// Attributes
		
		$this->phpdocComment ("Class attributes\n@var array");
		$this->addLine ();
		$this->generateAttributes ();
		$this->addLine ();
		
		// Database connection
		// Specify if not the default
		
		if ($this->get ('table') && $this->get ('database') != $this->db->getDatabaseName ())
		{
			
			// Create new database tool

			$db		= new Db;
			
			// Find database resource name from table name
			
			$dbName	= array_search ($this->get ('database'), $db->getDatabases ());
			
			// Set default class database resource
			
			$this->phpdocComment ("Default class resources\n@var array");
			$this->addLine ();
			$this->addLine ('protected static $defaultResources	= array (\'db\' => array (\'db\', \'' . $dbName . '\'));');
			$this->addLine ();
			
		}
		
		// End class
		
		$this->tabDown ();
		$this->addLine ('}');
		$this->addLine ();
		$this->lineComment ('End ' . $this->get ('name') . ' Class');
		
		// Return class
		
		return $this->class;
		
	}
1268322
protected function setupDefaultClasses()
    {
        $defaultClasses = self::config()->get('default_classes');
        if ($defaultClasses) {
            foreach ($defaultClasses as $class) {
                $this->addExtraClass($class);
            }
        }
    }
1118448
private function generateClass(): ServiceDTOGenerator
    {
        $this->DTOFile = (new PhpFile())
            ->addComment('This file is auto-generated.');

        $namespace = $this->inputData['namespace'] . '\\' . $this->inputData['module'] . 'Module\\' . $this->inputData['type'];

        $this->DTOClass = $this->DTOFile
            ->addNamespace($namespace)
            ->addClass($this->inputData['class'] . $this->inputData['type'])
            ->addComment($this->inputData['class'] . ' service ' . strtolower($this->inputData['type']) . PHP_EOL)
            ->addComment('@package ' . $namespace);

        return $this;
    }
1210084
private function classes() : string
    {
        $classes = '';

        if ($this->bg_color !== null) {
            $classes .= ' bg-' . $this->bg_color;
        }

        if ($this->text_color !== null) {
            $classes .= ' text-' . $this->text_color;
        }

        if ($this->striped === true) {
            $classes .= ' progress-bar-striped';
        }

        if ($this->animate === true) {
            $classes .= ' progress-bar-animated';
        }

        return $classes;
    }
17823
protected function generateFiles()
    {
        foreach ($this->files as $key => $file) {
            $file = $this->formatContent($file);

            $this->makeFile($key, $file);
        }
    }
145427
protected function generate_wsdl() {
        // Initialise WSDL.
        $this->wsdl = new wsdl($this->serviceclass, $this->serverurl);
        // Register service struct classes as complex types.
        foreach ($this->servicestructs as $structinfo) {
            $this->wsdl->add_complex_type($structinfo->classname, $structinfo->properties);
        }
        // Register the method for the WSDL generation.
        foreach ($this->servicemethods as $methodinfo) {
            $this->wsdl->register($methodinfo->name, $methodinfo->inputparams, $methodinfo->outputparams, $methodinfo->description);
        }
    }
81292
protected function generateSamples(): void
    {
        $module = str_after($this->getNameInput(), '/');

        $this->call('make:config', ['name' => 'config', '--module' => $this->getNameInput()]);
        $this->call('make:model', ['name' => 'Example', '--module' => $this->getNameInput()]);
        $this->call('make:policy', ['name' => 'ExamplePolicy', '--module' => $this->getNameInput()]);
        $this->call('make:provider', ['name' => ucfirst($module).'ServiceProvider', '--module' => $this->getNameInput()]);
        $this->call('make:command', ['name' => 'ExampleCommand', '--module' => $this->getNameInput()]);
        $this->call('make:controller', ['name' => 'ExampleController', '--module' => $this->getNameInput()]);
        $this->call('make:request', ['name' => 'ExampleRequest', '--module' => $this->getNameInput()]);
        $this->call('make:middleware', ['name' => 'ExampleMiddleware', '--module' => $this->getNameInput()]);
        $this->call('make:transformer', ['name' => 'ExampleTransformer', '--model' => 'Example', '--module' => $this->getNameInput()]);
        $this->call('make:datatable', ['name' => 'ExampleDatatable', '--model' => 'Example', '--transformer' => 'ExampleTransformer', '--module' => $this->getNameInput()]);

        $this->warn('Optionally create migrations and seeds (it may take some time):');
        $this->warn("artisan make:migration create_{$module}_example_table --module {$this->getNameInput()}");
        $this->warn("artisan make:seeder ExampleSeeder --module {$this->getNameInput()}");
    }
362820
public function generatePropertyMapClass()
    {
        $classMap = array();

        foreach($this->elementClassFinder as $classFile)
        {
            /** @var \Symfony\Component\Finder\SplFileInfo $classFile */
            $className = str_replace(array('\\', 'src/', '/', '.php'), array('/', '', '\\', ''), $classFile->getRelativePathname());

            if (false !== strpos($className, 'Abstract') || false !== strpos($className, 'Interface'))
                continue;

            $namespacedClassName = $this->elementClassNamespace.$className;
            $reflectionClass = new \ReflectionClass($namespacedClassName);
            $classMap[$namespacedClassName] = $this->createMapEntry($reflectionClass);
        }

        foreach($this->resourceClassFinder as $classFile)
        {
            /** @var \Symfony\Component\Finder\SplFileInfo $classFile */
            $className = str_replace(array('\\', 'src/', '/', '.php'), array('/', '', '\\', ''), $classFile->getRelativePathname());

            if (false !== strpos($className, 'Abstract') || false !== strpos($className, 'Interface'))
                continue;

            $namespacedClassName = $this->resourceClassNamespace.$className;
            $reflectionClass = new \ReflectionClass($namespacedClassName);
            $classMap[$namespacedClassName] = $this->createMapEntry($reflectionClass);
        }

        $outputFile = $this->outputDir.$this->outputClassName.'.php';

        $data = str_replace("\n  ", "\n        ", var_export($classMap, true));
        $now = date('Y-m-d e');
        $outputString = <<<PHP
<?php

/**
 * This class is automatically generated by php-fhir-object-mapper, do not edit!
 *
 * Created: {$now}
 */
class {$this->outputClassName} implements \\ArrayAccess {

    /** @var array */
    private \$_classMap = {$data};

    public function offsetSet(\$offset, \$value) {
        throw new \\BadMethodCallException('You may not add objects to this map post-creation.');
    }

    public function offsetExists(\$offset) {
        return isset(\$this->_classMap[\$offset]);
    }

    public function offsetUnset(\$offset) {
        throw new \\BadMethodCallException('You may not remove objects from this map post-creation.');
    }

    public function offsetGet(\$offset) {
        if (isset(\$this->_classMap[\$offset]))
            return \$this->_classMap[\$offset];

        throw new \OutOfRangeException('No FHIR class named "'.\$offset.'" exists in this map.');
    }
}
PHP;
        return (bool)file_put_contents($outputFile, $outputString);
    }
902095
public function generateCommands(array $classes = null)
    {
        if (!isset($classes)) {
            $classes = array();
        }
        $path = dirname(__DIR__) . '/Api';

        if (\Phar::running(false)) {
            $iterator = new \Phar($path);
        } else {
            $iterator = new \DirectoryIterator($path);
        }

        foreach ($iterator as $file) {
            if (fnmatch('*.php', $file->getPathName())) {
                $classes[] = Application::API_NAMESPACE . basename($file, '.php');
            }
        }

        $commands = array();

        foreach ($classes as $class) {
            $api = new \ReflectionClass($class);
            if ($api->isAbstract()) {
                // skip abtract classes
                continue;
            }

            foreach ($api->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
                if (strstr($method->getName(), '__')) {
                    // skip magics
                    continue;
                }
                $commands[] = $this->generateCommand(strtolower($api->getShortName()), $method);
            }
        }
        return $commands;
    }
1304219
public function classes()
    {
        $classes = func_get_args();
        if (!empty($classes)) {
            $this->attributes['class'] = implode(',', $classes);
        }

        return $this;
    }
1016705
public function constructClasses() {
		$timer = 'controllerConstructClasses';
		Common::startTimer($timer, __d('common', "Event: Controller.constructClasses"));

		$properties = array('components', 'helpers');
		$result = $this->triggerEvent('Controller.constructClasses', $this);

		$this->_mergeControllerVars();
		foreach ($properties as $property) {
			if (!isset($result[$property])) {
				continue;
			}
			$this->{$property} = Hash::merge(
				Hash::normalize($result[$property]),
				Hash::normalize((array) $this->{$property})
			);
			unset($result[$property]);
		}

		$this->_set($result);
		Common::stopTimer($timer);
		parent::constructClasses();
	}
295472
protected function _buildClass()
    {
        $defineData = $this->_extractData($this->elements);

        $defineParam = $this->parameters;
        $defineProps = $this->properties;

        $docBlock = '';
        foreach ($defineData as $key => $element) {
            $type = $element['type'];
            if ('scalar' === $type) {
                $type = 'string';
            }

            $docBlock .= "\n * @property ".$type.' $'.$key.' '.(isset($element['options']['label']) ? $element['options']['label'] : '');
        }

        array_walk($defineData, function (&$value, $key) {
                    $value = "->defineData('".$key."', '".$value['type']."', ".var_export($value['options'], true).")";
                });
        array_walk($defineParam, function (&$value, $key) {
                    $value = "->defineParam('".$key."', ".var_export($value, true).")";
                });
        array_walk($defineProps, function (&$value, $key) {
                    $value = "->defineProperty('".$key."', ".var_export($value, true).")";
                });

        $phpCode = str_replace(array('<namespace>',
            '<classname>',
            '<repository>',
            '<extends>',
            '<interface>',
            '<trait>',
            '<defineDatas>',
            '<defineParam>',
            '<defineProps>',
            '<docblock>', ), array($this->namespace,
            $this->classname,
            $this->repository,
            $this->extends,
            $this->interfaces,
            $this->traits,
            (0 < count($defineData)) ? '$this'.implode('', $defineData).';' : '',
            (0 < count($defineParam)) ? '$this'.implode('', $defineParam).';' : '',
            (0 < count($defineProps)) ? '$this'.implode('', $defineProps).';' : '',
            $docBlock, ), $this->template);

        return $phpCode;
    }
440958
public function generateResources()
    {
        $this->console->call('component:make-seed', [
            'name'      => $this->getName(),
            'component' => $this->getName(),
            '--master'  => true,
        ]);

        $this->console->call('component:make-provider', [
            'name'      => $this->getName() . 'ServiceProvider',
            'component' => $this->getName(),
            '--master'  => true,
        ]);

        $this->console->call('component:make-controller', [
            'controller' => $this->getName() . 'Controller',
            'component'  => $this->getName(),
        ]);
    }
952017
public function Classes(){
        $classes = array($this->config()->get('base_class'));
        if ($this->Style) {
            $classes[] = strtolower($this->Style).'-'.strtolower(preg_replace('/([a-z]+)([A-Z0-9])/', '$1-$2', get_called_class()));
        }else{
            $classes[] = strtolower(preg_replace('/([a-z]+)([A-Z0-9])/', '$1-$2', get_called_class()));
        }
        return implode(' ',$classes);
    }
251653
protected function generate()
	{
		if ( $this->fields ) {
			parent::fire();

			if ( $this->log ) {
				$file = $this->datePrefix . '_' . $this->migrationName;
				$this->repository->log($file, $this->batch);
			}
		}
	}