HistoryHydratorFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 7
dl 0
loc 29
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 23 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DataFlowServer\Authorization\Factory;
5
6
use Interop\Container\ContainerInterface;
7
use SlayerBirden\DataFlowServer\Doctrine\Hydrator\Strategy\DecoratedStrategy;
8
use SlayerBirden\DataFlowServer\Doctrine\Hydrator\Strategy\Decoration\NullDecorator;
9
use SlayerBirden\DataFlowServer\Doctrine\Hydrator\Strategy\NestedEntityStrategy;
10
use Zend\Hydrator\ClassMethods;
11
use Zend\Hydrator\NamingStrategy\MapNamingStrategy;
12
use Zend\Hydrator\Strategy\DateTimeFormatterStrategy;
13
use Zend\ServiceManager\Factory\FactoryInterface;
14
15
final class HistoryHydratorFactory implements FactoryInterface
16
{
17
    /**
18
     * @inheritdoc
19
     */
20 2
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
21
    {
22 2
        $permissionStrat = new NestedEntityStrategy(
23 2
            (new PermissionHydratorFactory())($container, 'PermissionHydrator')
24
        );
25
26 2
        $hydrator = new ClassMethods();
27 2
        $hydrator->addStrategy('user', new NestedEntityStrategy(new ClassMethods()));
28 2
        $hydrator->addStrategy('owner', new NestedEntityStrategy(new ClassMethods()));
29 2
        $hydrator->addStrategy(
30 2
            'permission',
31 2
            new DecoratedStrategy($permissionStrat, new NullDecorator())
32
        );
33 2
        $hydrator->addStrategy('at', new DateTimeFormatterStrategy());
34
35 2
        $hydrator->setNamingStrategy(new MapNamingStrategy([
36 2
            'change_action' => 'changeAction',
37
        ], [
38 2
            'changeAction' => 'change_action',
39
        ]));
40
41 2
        return $hydrator;
42
    }
43
}
44