FkSetterBuilder   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 22
rs 10
c 1
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPathTemplate() 0 3 1
A getFileTemplate() 0 3 1
A __construct() 0 10 4
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of FlexPHP.
4
 *
5
 * (c) Freddie Gar <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace FlexPHP\Generator\Domain\Builders\Entity;
11
12
use FlexPHP\Generator\Domain\Builders\AbstractBuilder;
13
14
final class FkSetterBuilder extends AbstractBuilder
15
{
16
    public function __construct(string $name, string $type, bool $required, string $table = '')
17
    {
18
        $name = $this->getInflector()->camelProperty($name);
19
        $setter = $this->getInflector()->pascalProperty($name);
20
        $type = $type !== 'self' ? $this->getInflector()->entity($type) : $type;
21
        $typeName = $type !== 'self'
22
            ? $this->getInflector()->camelProperty($type)
23
            : $this->getInflector()->camelProperty($this->getInflector()->entity($table ?: $type));
24
25
        parent::__construct(\compact('name', 'setter', 'type', 'typeName', 'required'));
26
    }
27
28
    protected function getFileTemplate(): string
29
    {
30
        return 'FkSetter.php.twig';
31
    }
32
33
    protected function getPathTemplate(): string
34
    {
35
        return \sprintf('%1$s/FlexPHP/Entity', parent::getPathTemplate());
36
    }
37
}
38