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.

AbstractCheckout::addStep()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.0534
c 0
b 0
f 0
cc 4
eloc 14
nc 4
nop 2
1
<?php
2
3
namespace Magium\Magento\Actions\Checkout;
4
5
use Magium\Magento\Actions\Checkout\Steps\StepInterface;
6
abstract class AbstractCheckout
7
{
8
    
9
    protected $steps = [];
10
    
11
    public function addStep(StepInterface $step, $before = null)
12
    {
13
14
        if ($before === null) {
15
            $this->steps[] = $step;
16
            return;
17
        }
18
        $key = array_search($before, $this->steps);
19
        $stepCount = count($this->steps);
20
        if ($key !== false) {
21
            $steps = array_slice($this->steps, 0, $key);
22
            $steps[] = $step;
23
            for ($i = $key; $i < $stepCount; $i++) {
24
                $steps[] = $this->steps[$i];
25
            }
26
            $this->steps = $steps;
27
        } else {
28
            $this->steps[] = $step;
29
        }
30
        
31
    }
32
    
33
    public function getStepInstance($class)
34
    {
35
        foreach ($this->steps as $step) {
36
            if ($step instanceof $class) {
37
                return $step;
38
            }
39
        }
40
    }
41
    
42
    public function execute()
43
    {
44
        foreach ($this->steps as $step) {
45
            if ($step instanceof StepInterface) {
46
                $continue = $step->execute();
47
                if (!$continue) return;
48
49
                $continue = $step->nextAction();
50
                if (!$continue) return;
51
            }
52
        }
53
    }
54
    
55
}