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