Completed
Push — master ( 178a08...5c0b6f )
by Oleg
05:22
created

PasswordHydratorFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 6
dl 0
loc 25
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 19 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DataFlowServer\Authentication\Factory;
5
6
use Interop\Container\ContainerInterface;
7
use SlayerBirden\DataFlowServer\Authentication\Hydrator\Strategy\HashStrategy;
8
use SlayerBirden\DataFlowServer\Doctrine\Hydrator\Strategy\NestedEntityStrategy;
9
use Zend\Hydrator\ClassMethods;
10
use Zend\Hydrator\NamingStrategy\MapNamingStrategy;
11
use Zend\Hydrator\Strategy\BooleanStrategy;
12
use Zend\Hydrator\Strategy\DateTimeFormatterStrategy;
13
use Zend\ServiceManager\Factory\FactoryInterface;
14
15
class PasswordHydratorFactory implements FactoryInterface
16
{
17
    /**
18
     * @inheritdoc
19
     */
20 6
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
21
    {
22 6
        $extraction = new ClassMethods();
23 6
        $extraction->addStrategy('created_at', new DateTimeFormatterStrategy());
24 6
        $extraction->addStrategy('due', new DateTimeFormatterStrategy());
25 6
        $extraction->addStrategy('active', new BooleanStrategy(1, 0));
26 6
        $extraction->addStrategy('owner', new NestedEntityStrategy(new ClassMethods()));
27 6
        $extraction->addStrategy('hash', $container->get(HashStrategy::class));
28
29 6
        $extraction->setNamingStrategy(new MapNamingStrategy([
30 6
            'created_at' => 'createdAt',
31
            'password' => 'hash',
32
        ], [
33 6
            'isActive' => 'active',
34
            'createdAt' => 'created_at',
35
        ]));
36
37 6
        return $extraction;
38
    }
39
}
40