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\Update;
5
6
use Nette\PhpGenerator\PhpLiteral;
7
use Psr\Log\LoggerInterface;
8
use SlayerBirden\DFCodeGeneration\Generator\Config\ConfigPartInterface;
9
use SlayerBirden\DFCodeGeneration\Generator\DataProvider\DataProviderInterface;
10
11
final class AbstractFactory implements ConfigPartInterface
12
{
13
    const PART_KEY = \Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory::class;
14
15
    /**
16
     * @var DataProviderInterface
17
     */
18
    private $dataProvider;
19
20 2
    public function __construct(DataProviderInterface $dataProvider)
21
    {
22 2
        $this->dataProvider = $dataProvider;
23 2
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28 2
    public function getConfig(): array
29
    {
30 2
        $name = '\\' . $this->getControllerNamespace() . '\Update' . $this->getEntityClassName() . 'Action::class';
31
        return [
32 2
            $name => [
33 2
                new PhpLiteral('\SlayerBirden\DataFlowServer\Doctrine\Persistence\EntityManagerRegistry::class'),
34 2
                $this->dataProvider->provide()['hydrator_name'],
35
                LoggerInterface::class,
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 getEntityClassName(): string
49
    {
50 2
        return $this->dataProvider->provide()['entityClassName'];
51
    }
52
53 2
    private function getControllerNamespace(): string
54
    {
55 2
        return $this->dataProvider->provide()['controller_namespace'];
56
    }
57
}
58