StepReplacement::getDescription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
namespace PSB\Core\Pipeline;
3
4
5
use PSB\Core\ObjectBuilder\BuilderInterface;
6
use PSB\Core\Util\Guard;
7
8
class StepReplacement
9
{
10
    /**
11
     * @var string
12
     */
13
    private $idToReplace;
14
15
    /**
16
     * @var string
17
     */
18
    private $stepFqcn;
19
20
    /**
21
     * @var callable|null
22
     */
23
    private $factory;
24
25
    /**
26
     * @var null|string
27
     */
28
    private $description;
29
30
    /**
31
     * StepReplacement constructor.
32
     *
33
     * @param string        $idToReplace
34
     * @param string        $stepFqcn
35
     * @param callable|null $factory
36
     * @param string|null   $description
37
     */
38 12 View Code Duplication
    public function __construct($idToReplace, $stepFqcn, callable $factory = null, $description = null)
39
    {
40 12
        Guard::againstNullAndEmpty('idToReplace', $idToReplace);
41 11
        Guard::againstNullAndEmpty('stepClass', $stepFqcn);
42
43 10
        $this->idToReplace = $idToReplace;
44 10
        $this->stepFqcn = $stepFqcn;
45 10
        $this->factory = $factory;
46 10
        $this->description = $description;
47 10
    }
48
49
    /**
50
     * @param BuilderInterface $builder
51
     */
52 2
    public function registerInBuilder(BuilderInterface $builder)
53
    {
54 2
        if ($this->factory) {
55 2
            $builder->defineSingleton($this->stepFqcn, $this->factory);
56
        }
57 2
    }
58
59
    /**
60
     * @return string
61
     */
62 2
    public function getIdToReplace()
63
    {
64 2
        return $this->idToReplace;
65
    }
66
67
    /**
68
     * @return string
69
     */
70 2
    public function getStepFqcn()
71
    {
72 2
        return $this->stepFqcn;
73
    }
74
75
    /**
76
     * @return callable|null
77
     */
78 2
    public function getFactory()
79
    {
80 2
        return $this->factory;
81
    }
82
83
    /**
84
     * @return null|string
85
     */
86 2
    public function getDescription()
87
    {
88 2
        return $this->description;
89
    }
90
}
91