AbstractFactory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 46
rs 10
c 0
b 0
f 0
ccs 15
cts 15
cp 1
wmc 5

5 Methods

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