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

DecoratedProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
ccs 0
cts 9
cp 0
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\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