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

DecoratedProvider::provide()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
ccs 0
cts 5
cp 0
crap 6
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