FkGetterBuilder::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 3
dl 0
loc 8
rs 10
c 1
b 0
f 0
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 FkGetterBuilder extends AbstractBuilder
15
{
16
    public function __construct(string $name, string $type, bool $required)
17
    {
18
        $name = $this->getInflector()->camelProperty($name);
19
        $getter = $this->getInflector()->camelProperty($name);
20
        $type = $type !== 'self' ? $this->getInflector()->entity($type) : $type;
21
        $typeName = $this->getInflector()->camelProperty($type);
22
23
        parent::__construct(\compact('name', 'getter', 'type', 'typeName', 'required'));
24
    }
25
26
    public function build(): string
27
    {
28
        return \rtrim(parent::build());
29
    }
30
31
    protected function getFileTemplate(): string
32
    {
33
        return 'FkGetter.php.twig';
34
    }
35
36
    protected function getPathTemplate(): string
37
    {
38
        return \sprintf('%1$s/FlexPHP/Entity', parent::getPathTemplate());
39
    }
40
}
41