Passed
Push — master ( 743cc2...6ffec3 )
by Oleg
02:50
created

DecoratedProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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 0
cts 3
cp 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DFCodeGeneration\Generator\Controllers;
5
6
class DecoratedProvider extends SimpleProvider
7
{
8
    /**
9
     * @var DataProviderDecoratorInterface[]
10
     */
11
    private $decorators;
12
13
    public function __construct(string $entityClassName, DataProviderDecoratorInterface ...$decorators)
14
    {
15
        parent::__construct($entityClassName);
16
        $this->decorators = $decorators;
17
    }
18
19
    /**
20
     * @return array
21
     * @throws \ReflectionException
22
     */
23
    public function provide(): array
24
    {
25
        $data = parent::provide();
26
27
        foreach ($this->decorators as $decorator) {
28
            $data = $decorator->decorate($data);
29
        }
30
31
        return $data;
32
    }
33
}
34