Completed
Push — develop ( e7cba6...164e03 )
by Freddie
13:34
created

TranslateBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFileTemplate() 0 3 1
A getPathTemplate() 0 3 1
A __construct() 0 10 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\Translate;
11
12
use FlexPHP\Generator\Domain\Builders\AbstractBuilder;
13
use FlexPHP\Schema\Constants\Keyword;
14
use Jawira\CaseConverter\Convert;
15
16
final class TranslateBuilder extends AbstractBuilder
17
{
18
    public function __construct(string $entity, array $properties)
19
    {
20
        $entity = (new Convert($this->getSingularize($entity)))->toTitle();
21
        $headers = \array_reduce($properties, function (array $result, array $property) {
22
            $result[$this->getCamelCase($property[Keyword::NAME])] = (new Convert($property[Keyword::NAME]))->toTitle();
23
24
            return $result;
25
        }, []);
26
27
        parent::__construct(\compact('entity', 'headers'));
28
    }
29
30
    protected function getFileTemplate(): string
31
    {
32
        return 'translate.php.twig';
33
    }
34
35
    protected function getPathTemplate(): string
36
    {
37
        return \sprintf('%1$s/Symfony/v43/templates', parent::getPathTemplate());
38
    }
39
}
40