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

DecoratedStrategy::extract()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
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