Completed
Push — master ( f81cf6...7fbbb0 )
by Oleg
03:40
created

DecoratedProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DFCodeGeneration\Generator\DataProvider;
5
6
final class DecoratedProvider implements DataProviderInterface
7
{
8
    /**
9
     * @var DataProviderDecoratorInterface[]
10
     */
11
    private $decorators;
12
    /**
13
     * @var DataProviderInterface
14
     */
15
    private $dataProvider;
16
17 2
    public function __construct(DataProviderInterface $dataProvider, DataProviderDecoratorInterface ...$decorators)
18
    {
19 2
        $this->decorators = $decorators;
20 2
        $this->dataProvider = $dataProvider;
21 2
    }
22
23 2
    public function provide(): array
24
    {
25 2
        $data = $this->dataProvider->provide();
26
27 2
        foreach ($this->decorators as $decorator) {
28 2
            $data = $decorator->decorate($data);
29
        }
30
31 2
        return $data;
32
    }
33
}
34