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.
Completed
Push — develop ( d16b40...f12d2b )
by David
11:46
created

ConditionCollection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
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 Assert\Assertion;
18
19
/**
20
 * Class ConditionCollection contains child conditions which are called during match.
21
 *
22
 * @package Netzmacht\Workflow\Flow\Transition\Condition
23
 */
24 View Code Duplication
abstract class ConditionCollection implements Condition
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
{
26
    /**
27
     * All child conditions of the collection.
28
     *
29
     * @var Condition[]
30
     */
31
    protected $conditions = array();
32
33
    /**
34
     * ConditionCollection constructor.
35
     *
36
     * @param Condition[]|iterable $conditions List of child conditions.
37
     */
38
    public function __construct(iterable $conditions = [])
39
    {
40
        $this->addConditions($conditions);
0 ignored issues
show
Bug introduced by
It seems like $conditions defined by parameter $conditions on line 38 can also be of type array<integer,object<Net...\Transition\Condition>>; however, Netzmacht\Workflow\Flow\...ection::addConditions() does only seem to accept object<Netzmacht\Workflo...on\Transition\iterable>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
41
    }
42
43
    /**
44
     * Add condition.
45
     *
46
     * @param Condition $condition Condition being added.
47
     *
48
     * @return $this
49
     */
50
    public function addCondition(Condition $condition): self
51
    {
52
        $this->conditions[] = $condition;
53
54
        return $this;
55
    }
56
57
    /**
58
     * Remove condition from collection.
59
     *
60
     * @param Condition $condition Condition being removed.
61
     *
62
     * @return $this
63
     */
64
    public function removeCondition(Condition $condition): self
65
    {
66
        foreach ($this->conditions as $index => $value) {
67
            if ($value === $condition) {
68
                unset($this->conditions[$index]);
69
            }
70
        }
71
72
        return $this;
73
    }
74
75
    /**
76
     * Get child conditions.
77
     *
78
     * @return Condition[]|iterable
79
     */
80
    public function getConditions(): iterable
81
    {
82
        return $this->conditions;
83
    }
84
85
    /**
86
     * Add multiple conditions.
87
     *
88
     * @param iterable $conditions Array of conditions being added.
89
     *
90
     * @return $this
91
     *
92
     * @throws \Assert\InvalidArgumentException If array contains an invalid condition.
93
     */
94
    public function addConditions(iterable $conditions): self
95
    {
96
        Assertion::allIsInstanceOf($conditions, Condition::class);
97
98
        foreach ($conditions as $condition) {
99
            $this->addCondition($condition);
100
        }
101
102
        return $this;
103
    }
104
}
105