AbstractFactory::getControllerNamespace()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DFCodeGeneration\Generator\Config\Parts\Gets;
5
6
use Psr\Log\LoggerInterface;
7
use SlayerBirden\DFCodeGeneration\Generator\Config\ConfigPartInterface;
8
use SlayerBirden\DFCodeGeneration\Generator\DataProvider\DataProviderInterface;
9
10
final class AbstractFactory implements ConfigPartInterface
11
{
12
    const PART_KEY = \Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory::class;
13
14
    /**
15
     * @var DataProviderInterface
16
     */
17
    private $dataProvider;
18
19 2
    public function __construct(DataProviderInterface $dataProvider)
20
    {
21 2
        $this->dataProvider = $dataProvider;
22 2
    }
23
24
    /**
25
     * @inheritdoc
26
     */
27 2
    public function getConfig(): array
28
    {
29 2
        $pluralEntityName = $this->dataProvider->provide()['pluralEntityName'];
30 2
        $name = '\\' . $this->getControllerNamespace() . '\Get' . $pluralEntityName . 'Action::class';
31
        return [
32 2
            $name => [
33 2
                $this->dataProvider->provide()['entityClassName'] . 'Repository',
34
                LoggerInterface::class,
35 2
                $this->dataProvider->provide()['hydrator_name'],
36
            ]
37
        ];
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43 2
    public function getCode(): string
44
    {
45 2
        return self::PART_KEY;
46
    }
47
48 2
    private function getControllerNamespace(): string
49
    {
50 2
        return $this->dataProvider->provide()['controller_namespace'];
51
    }
52
}
53