DbConfigHydratorFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DataFlowServer\Db\Factory;
5
6
use Interop\Container\ContainerInterface;
7
use SlayerBirden\DataFlowServer\Doctrine\Hydrator\Strategy\NestedEntityStrategy;
8
use SlayerBirden\DataFlowServer\Doctrine\Hydrator\Strategy\ObscuredStrategy;
9
use SlayerBirden\DataFlowServer\Doctrine\Hydrator\Strategy\RegexpObscuredStrategy;
10
use Zend\Hydrator\ClassMethods;
11
use Zend\Hydrator\HydratorInterface;
12
use Zend\ServiceManager\Factory\FactoryInterface;
13
14
final class DbConfigHydratorFactory implements FactoryInterface
15
{
16
    /**
17
     * @inheritdoc
18
     */
19 30
    public function __invoke(
20
        ContainerInterface $container,
21
        $requestedName,
22
        array $options = null
23
    ): HydratorInterface {
24 30
        $extraction = new ClassMethods();
25 30
        $extraction->addStrategy('owner', new NestedEntityStrategy(new ClassMethods()));
26 30
        $extraction->addStrategy('password', new ObscuredStrategy());
27 30
        $extraction->addStrategy('url', new RegexpObscuredStrategy(
28 30
            '/:\w+@/',
29 30
            ':*****@'
30
        ));
31
32 30
        return $extraction;
33
    }
34
}
35