Configurator   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 15
dl 0
loc 46
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A execute() 0 23 5
1
<?php declare(strict_types=1);
2
3
4
namespace Xervice\Configurator\Business\Model\Engine;
5
6
7
use DataProvider\StepDataDataProvider;
0 ignored issues
show
Bug introduced by
The type DataProvider\StepDataDataProvider was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Xervice\Configurator\Business\Model\Exception\ConfiguratorException;
9
use Xervice\Configurator\Business\Model\Step\StepCollection;
10
11
class Configurator implements ConfiguratorInterface
12
{
13
    /**
14
     * @var \Xervice\Configurator\Business\Model\Step\StepCollection
15
     */
16
    private $stepCollection;
17
18
    /**
19
     * Configurator constructor.
20
     *
21
     * @param \Xervice\Configurator\Business\Model\Step\StepCollection $stepCollection
22
     */
23 2
    public function __construct(StepCollection $stepCollection)
24
    {
25 2
        $this->stepCollection = $stepCollection;
26 2
    }
27
28
    /**
29
     * @param \DataProvider\StepDataDataProvider $dataProvider
30
     *
31
     * @return \DataProvider\StepDataDataProvider
32
     * @throws \Xervice\Configurator\Business\Model\Exception\ConfiguratorException
33
     */
34 2
    public function execute(StepDataDataProvider $dataProvider): StepDataDataProvider
35
    {
36 2
        $step = null;
37
38 2
        foreach ($this->stepCollection as $step) {
39 2
            $step->setData($dataProvider);
40
41 2
            if (!$step->done()) {
42 2
                if (!$step->ready()) {
43 1
                    throw new ConfiguratorException(
44 1
                        sprintf(
45 1
                            'Step %s is not ready, but all previous steps are done',
46 1
                            \get_class($step)
47
                        )
48
                    );
49
                }
50
51 1
                $step->execute();
52 1
                $this->execute($step->getData());
53
            }
54
        }
55
56 1
        return $step ? $step->getData() : $dataProvider;
57
    }
58
}