GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

JoinNodes   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 46
ccs 0
cts 20
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 3
A getStep() 0 10 3
1
<?php
2
/**
3
 * @link    https://github.com/old-town/old-town-workflow
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow;
7
8
use OldTown\Workflow\Exception\InternalWorkflowException;
9
use \OldTown\Workflow\JoinNodes\DummyStep;
10
use OldTown\Workflow\Spi\StepInterface;
11
12
/**
13
 * Class JoinNodes
14
 *
15
 * @package OldTown\Workflow
16
 */
17
class JoinNodes
18
{
19
    /**
20
     * @var StepInterface[]
21
     */
22
    protected $steps;
23
24
    /**
25
     * @var DummyStep
26
     */
27
    protected $dummy;
28
29
    /**
30
     * @param array $steps
31
     *
32
     * @throws \OldTown\Workflow\Exception\InternalWorkflowException
33
     */
34
    public function __construct(array $steps = [])
35
    {
36
        foreach ($steps as $step) {
37
            if (!$step instanceof StepInterface) {
38
                $errMsg = 'Некорректная коллекция из шагов workflow';
39
                throw new InternalWorkflowException($errMsg);
40
            }
41
        }
42
43
        $this->dummy = new DummyStep();
44
        $this->steps = $steps;
45
    }
46
47
    /**
48
     * @param $stepId
49
     *
50
     * @return DummyStep|StepInterface
51
     */
52
    public function getStep($stepId)
53
    {
54
        foreach ($this->steps as $step) {
55
            if ($step->getId() === $stepId) {
56
                return $step;
57
            }
58
        }
59
60
        return $this->dummy;
61
    }
62
}
63