ResponseMessageBuilder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 2
dl 0
loc 11
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
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 7
 */
10
namespace FlexPHP\Generator\Domain\Builders\Controller;
11 7
12
use FlexPHP\Generator\Domain\Builders\AbstractBuilder;
13
use FlexPHP\Schema\Constants\Action;
14 7
use FlexPHP\Schema\SchemaInterface;
15
16 7
final class ResponseMessageBuilder extends AbstractBuilder
17
{
18
    public function __construct(SchemaInterface $schema, string $action)
19 7
    {
20
        $action = $this->getInflector()->camelAction($action);
21 7
        $entity = $this->getInflector()->entity($schema->name());
22
        $item = $this->getInflector()->item($schema->name());
23
        $items = $this->getInflector()->items($schema->name());
24
        $templates = $item;
25
        $route = $this->getInflector()->route($schema->name());
26
        $hasFilter = $schema->hasAction(Action::FILTER);
27
28
        parent::__construct(\compact('entity', 'route', 'action', 'item', 'items', 'templates', 'hasFilter'));
29
    }
30
31
    public function build(): string
32
    {
33
        return \rtrim(parent::build());
34
    }
35
36
    protected function getFileTemplate(): string
37
    {
38
        return 'ResponseMessage.php.twig';
39
    }
40
41
    protected function getPathTemplate(): string
42
    {
43
        return \sprintf('%1$s/Symfony/src/Controller', parent::getPathTemplate());
44
    }
45
}
46