AbstractFactory::getEntityClassName()   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\Delete;
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() . '\Delete' . $this->getEntityClassName() . 'Action::class';
31 2
        $hydratorName = $this->dataProvider->provide()['hydrator_name'];
32
        return [
33 2
            $name => [
34 2
                new PhpLiteral('\SlayerBirden\DataFlowServer\Doctrine\Persistence\EntityManagerRegistry::class'),
35 2
                $hydratorName,
36
                LoggerInterface::class,
37
            ]
38
        ];
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44 2
    public function getCode(): string
45
    {
46 2
        return self::PART_KEY;
47
    }
48
49 2
    private function getEntityClassName(): string
50
    {
51 2
        return $this->dataProvider->provide()['entityClassName'];
52
    }
53
54 2
    private function getControllerNamespace(): string
55
    {
56 2
        return $this->dataProvider->provide()['controller_namespace'];
57
    }
58
}
59