GatewayBuilder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPathTemplate() 0 3 1
A getFileTemplate() 0 3 1
A __construct() 0 14 1
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\Gateway;
11
12
use FlexPHP\Generator\Domain\Builders\AbstractBuilder;
13
use FlexPHP\Schema\SchemaInterface;
14
15
final class GatewayBuilder extends AbstractBuilder
16
{
17
    public function __construct(SchemaInterface $schema, array $actions)
18
    {
19
        $entity = $this->getInflector()->entity($schema->name());
20
        $item = $this->getInflector()->item($schema->name());
21
        $fkFns = $this->getFkFunctions($schema->fkRelations());
22
        $typeHint = $schema->pkTypeHint();
23
        $actions = \array_reduce($actions, function (array $result, string $action) {
24
            $result[] = $this->getInflector()->camelAction($action);
25
26
            return $result;
27
        }, []);
28
        $header = self::getHeaderFile();
29
30
        parent::__construct(\compact('header', 'entity', 'actions', 'item', 'fkFns', 'typeHint'));
31
    }
32
33
    protected function getFileTemplate(): string
34
    {
35
        return 'Gateway.php.twig';
36
    }
37
38
    protected function getPathTemplate(): string
39
    {
40
        return \sprintf('%1$s/FlexPHP/Gateway', parent::getPathTemplate());
41
    }
42
}
43