Completed
Push — master ( a199f7...eac768 )
by Oleg
06:42
created

HistoryHydratorFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
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 27
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 21 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((new PermissionHydratorFactory())($container, $requestedName));
23
24 2
        $hydrator = new ClassMethods();
25 2
        $hydrator->addStrategy('user', new NestedEntityStrategy(new ClassMethods()));
26 2
        $hydrator->addStrategy('owner', new NestedEntityStrategy(new ClassMethods()));
27 2
        $hydrator->addStrategy(
28 2
            'permission',
29 2
            new DecoratedStrategy($permissionStrat, new NullDecorator())
30
        );
31 2
        $hydrator->addStrategy('at', new DateTimeFormatterStrategy());
32
33 2
        $hydrator->setNamingStrategy(new MapNamingStrategy([
34 2
            'change_action' => 'changeAction',
35
        ], [
36 2
            'changeAction' => 'change_action',
37
        ]));
38
39 2
        return $hydrator;
40
    }
41
}
42