Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
10 / 10
GenericGenerator
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
10 / 10
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 setup
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
5 / 5
 generate
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
<?php
declare(strict_types = 1);
namespace Siesta\Generator;
use Siesta\Config\GenericGeneratorConfig;
use Siesta\Contract\Generator;
use Siesta\Model\Entity;
/**
 * @author Gregor Müller
 */
class GenericGenerator
{
    /**
     * @var GenericGeneratorConfig
     */
    protected $config;
    /**
     * @var Generator
     */
    protected $generator;
    /**
     * ModelGenerator constructor.
     *
     * @param GenericGeneratorConfig $config
     */
    public function __construct(GenericGeneratorConfig $config)
    {
        $this->config = $config;
        $this->setup();
    }
    /**
     * @return Generator
     */
    protected function setup()
    {
        $generatorClassName = $this->config->getClassName();
        $this->generator = new $generatorClassName;
        foreach ($this->config->getPluginList() as $plugin) {
            $this->generator->addPlugin(new $plugin);
        }
    }
    /**
     * @param Entity $entity
     * @param string $baseDir
     */
    public function generate(Entity $entity, string $baseDir)
    {
        $this->generator->generate($entity, $baseDir);
    }
}