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

DecoratedStrategy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 39
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A extract() 0 8 2
A hydrate() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DataFlowServer\Doctrine\Hydrator\Strategy;
5
6
use SlayerBirden\DataFlowServer\Doctrine\Hydrator\Strategy\Decoration\DecoratorInterface;
7
use Zend\Hydrator\Strategy\StrategyInterface;
8
9
final class DecoratedStrategy implements StrategyInterface
10
{
11
    /**
12
     * @var StrategyInterface
13
     */
14
    private $strategy;
15
    /**
16
     * @var DecoratorInterface[]
17
     */
18
    private $decorators;
19
20 2
    public function __construct(StrategyInterface $strategy, DecoratorInterface ...$decorators)
21
    {
22 2
        $this->strategy = $strategy;
23 2
        $this->decorators = $decorators;
24 2
    }
25
26
    /**
27
     * {@inheritdoc}
28
     *
29
     * Decorate extraction
30
     */
31 2
    public function extract($value)
32
    {
33 2
        foreach ($this->decorators as $decorator) {
34 2
            $value = $decorator->getExtracted($this->strategy, $value);
35
        }
36
37 2
        return $value;
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43
    public function hydrate($value)
44
    {
45
        return $this->strategy->hydrate($value);
46
    }
47
}
48