UseCaseBuilder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
c 2
b 0
f 0
dl 0
loc 25
ccs 3
cts 3
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getFileTemplate() 0 3 1
A __construct() 0 8 1
A build() 0 3 1
A getPathTemplate() 0 3 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 7
 */
10
namespace FlexPHP\Generator\Domain\Builders\Controller;
11 7
12
use FlexPHP\Generator\Domain\Builders\AbstractBuilder;
13
use FlexPHP\Schema\SchemaInterface;
14 7
15
final class UseCaseBuilder extends AbstractBuilder
16 7
{
17
    public function __construct(SchemaInterface $schema, string $action)
18
    {
19 7
        $entity = $this->getInflector()->entity($schema->name());
20
        $action = $this->getInflector()->pascalAction($action);
21 7
        $item = $this->getInflector()->item($schema->name());
22
        $pkName = $this->getInflector()->camelProperty($schema->pkName());
23
24
        parent::__construct(\compact('entity', 'action', 'item', 'pkName'));
25
    }
26
27
    public function build(): string
28
    {
29
        return \rtrim(parent::build());
30
    }
31
32
    protected function getFileTemplate(): string
33
    {
34
        return 'UseCase.php.twig';
35
    }
36
37
    protected function getPathTemplate(): string
38
    {
39
        return \sprintf('%1$s/Symfony/src/Controller', parent::getPathTemplate());
40
    }
41
}
42