Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
66.67% covered (warning)
66.67%
2 / 3
CRAP
87.50% covered (success)
87.50%
7 / 8
ConstantPlugin
0.00% covered (danger)
0.00%
0 / 1
66.67% covered (warning)
66.67%
2 / 3
5.05
87.50% covered (success)
87.50%
7 / 8
 getUseClassNameList
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getDependantPluginList
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 generate
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
6 / 6
<?php
declare(strict_types = 1);
namespace Siesta\GeneratorPlugin\Entity;
use Siesta\CodeGenerator\CodeGenerator;
use Siesta\GeneratorPlugin\BasePlugin;
use Siesta\Model\Entity;
/**
 * @author Gregor Müller
 */
class ConstantPlugin extends BasePlugin
{
    /**
     * @param Entity $entity
     *
     * @return string[]
     */
    public function getUseClassNameList(Entity $entity) : array
    {
        return [];
    }
    /**
     * @return string[]
     */
    public function getDependantPluginList() : array
    {
        return [];
    }
    /**
     * @param Entity $entity
     * @param CodeGenerator $codeGenerator
     */
    public function generate(Entity $entity, CodeGenerator $codeGenerator)
    {
        $codeGenerator->addConstant("TABLE_NAME", $entity->getTableName());
        if ($entity->getIsDelimit()) {
            $codeGenerator->addConstant("DELIMIT_TABLE_NAME", $entity->getTableName());
        }
        foreach ($entity->getAttributeList() as $attribute) {
            $codeGenerator->addConstant("COLUMN_" . $attribute->getPhpName(), $attribute->getDBName());
        }
    }
}