AbstractFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 41
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getControllerNamespace() 0 3 1
A getConfig() 0 9 1
A __construct() 0 3 1
A getCode() 0 3 1
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