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.

PayloadPropertyCondition   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 61
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A match() 0 20 2
1
<?php
2
3
/**
4
 * Workflow library.
5
 *
6
 * @package    workflow
7
 * @author     David Molineus <[email protected]>
8
 * @copyright  2014-2017 netzmacht David Molineus
9
 * @license    LGPL 3.0 https://github.com/netzmacht/workflow
10
 * @filesource
11
 */
12
13
declare(strict_types=1);
14
15
namespace Netzmacht\Workflow\Flow\Condition\Transition;
16
17
use Netzmacht\Workflow\Flow\Context;
18
use Netzmacht\Workflow\Flow\Item;
19
use Netzmacht\Workflow\Flow\Transition;
20
use Netzmacht\Workflow\Util\Comparison;
21
22
/**
23
 * Class PayloadPropertyCondition
24
 */
25
class PayloadPropertyCondition implements Condition
26
{
27
    /**
28
     * Payload property name.
29
     *
30
     * @var string
31
     */
32
    private $property;
33
34
    /**
35
     * Expected value.
36
     *
37
     * @var mixed
38
     */
39
    private $value;
40
41
    /**
42
     * Comparison operator.
43
     *
44
     * @var string
45
     */
46
    private $operator;
47
48
    /**
49
     * PayloadPropertyCondition constructor.
50
     *
51
     * @param string $property Payload property name.
52
     * @param mixed  $value    Expected value.
53
     * @param string $operator Comparison operator.
54
     */
55
    public function __construct(string $property, $value, string $operator = Comparison::EQUALS)
56
    {
57
        $this->property = $property;
58
        $this->value    = $value;
59
        $this->operator = $operator;
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function match(Transition $transition, Item $item, Context $context): bool
66
    {
67
        $payloadValue = $context->getPayload()->get($this->property);
68
69
        if (Comparison::compare($payloadValue, $this->value, $this->operator)) {
70
            return true;
71
        }
72
73
        $context->addError(
74
            'transition.condition.payload_property.failed',
75
            [
76
                'property' => $this->property,
77
                'expected' => $this->value,
78
                'actual'   => $payloadValue,
79
                'operator' => $this->operator,
80
            ]
81
        );
82
83
        return false;
84
    }
85
}
86