PipelineFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 41
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A createStartingWith() 0 12 2
1
<?php
2
namespace PSB\Core\Pipeline;
3
4
5
use PSB\Core\ObjectBuilder\BuilderInterface;
6
7
class PipelineFactory
8
{
9
    /**
10
     * @var BuilderInterface
11
     */
12
    private $builder;
13
14
    /**
15
     * @var StepChainBuilderFactory
16
     */
17
    private $chainBuilderFactory;
18
19
    /**
20
     * @param BuilderInterface        $builder
21
     * @param StepChainBuilderFactory $chainBuilderFactory
22
     */
23 2
    public function __construct(BuilderInterface $builder, StepChainBuilderFactory $chainBuilderFactory)
24
    {
25 2
        $this->builder = $builder;
26 2
        $this->chainBuilderFactory = $chainBuilderFactory;
27 2
    }
28
29
    /**
30
     * @param string                $stageContextFqcn
31
     * @param PipelineModifications $pipelineModifications
32
     *
33
     * @return PipelineInterface
34
     */
35 1
    public function createStartingWith($stageContextFqcn, PipelineModifications $pipelineModifications)
36
    {
37 1
        $stepChainBuilder = $this->chainBuilderFactory->createChainBuilder($stageContextFqcn, $pipelineModifications);
38
39 1
        $stepRegistrations = $stepChainBuilder->build();
40 1
        $stepInstances = [];
41 1
        foreach ($stepRegistrations as $registration) {
42 1
            $stepInstances[] = $this->builder->build($registration->getStepFqcn());
43
        }
44
45 1
        return new Pipeline($stepInstances);
46
    }
47
}
48