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.

StatusCondition::passesCondition()   C
last analyzed

Complexity

Conditions 8
Paths 12

Size

Total Lines 29
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 72

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 29
ccs 0
cts 23
cp 0
rs 5.3846
cc 8
eloc 16
nc 12
nop 3
crap 72
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: shirshov
5
 * Date: 11.11.15
6
 * Time: 16:17
7
 */
8
9
namespace OldTown\Workflow\Util;
10
11
use OldTown\PropertySet\PropertySetInterface;
12
use OldTown\Workflow\ConditionInterface;
13
use OldTown\Workflow\Exception\WorkflowException;
14
use OldTown\Workflow\Spi\WorkflowEntryInterface;
15
use OldTown\Workflow\Spi\WorkflowStoreInterface;
16
use OldTown\Workflow\TransientVars\TransientVarsInterface;
17
18
/**
19
 * Simple utility condition that returns true if the current step's status is
20
 * the same as the required argument "status". Looks at ALL current steps unless
21
 * a stepId is given in the optional argument "stepId".
22
 *
23
 * @package OldTown\Workflow\Util
24
 */
25
class StatusCondition implements ConditionInterface
26
{
27
    /**
28
     * @param TransientVarsInterface $transientVars
29
     * @param array $args
30
     * @param PropertySetInterface $ps
31
     * @return bool
32
     *
33
     * @throws WorkflowException
34
     */
35
    public function passesCondition(TransientVarsInterface $transientVars, array $args = [], PropertySetInterface $ps)
36
    {
37
        $status = $args['status'];
38
        $stepId = array_key_exists('stepId', $args) ? (int)$args['stepId'] : 0;
39
40
        /** @var WorkflowEntryInterface $entry */
41
        $entry = $transientVars['entry'];
42
43
        /** @var WorkflowStoreInterface $store */
44
        $store = $transientVars['store'];
45
        $currentSteps = $store->findCurrentSteps($entry->getId());
46
47
        if ($stepId === 0) {
48
            foreach ($currentSteps as $step) {
49
                if ($status === $step->getStatus()) {
50
                    return true;
51
                }
52
            }
53
        } else {
54
            foreach ($currentSteps as $step) {
55
                if (($stepId === $step->getStepId())
56
                    && ($status === $step->getStatus())) {
57
                    return true;
58
                }
59
            }
60
        }
61
62
        return false;
63
    }
64
}
65