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

DecoratedProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 26
rs 10
c 0
b 0
f 0
ccs 9
cts 9
cp 1
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A provide() 0 9 2
A __construct() 0 4 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