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 — master ( 9000d2...f19783 )
by Time
06:05
created

Set   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 12
c 2
b 1
f 0
lcom 1
cbo 1
dl 0
loc 88
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A count() 0 4 1
A clear() 0 5 1
A contains() 0 4 2
A add() 0 4 1
A addRef() 0 13 3
A remove() 0 13 3
A isArrayCompatible() 0 4 1
1
<?php
2
3
namespace Pinq\Iterators\Common;
4
5
/**
6
 * Contains the common functionality for a ISet implementation
7
 *
8
 * @author Elliot Levin <[email protected]>
9
 */
10
trait Set
11
{
12
    /**
13
     * The array containing the values keyed by their identity hash.
14
     *
15
     * @var array
16
     */
17
    protected $values = [];
18
19
    /**
20
     * The amount of values in the set.
21
     *
22
     * @var int
23
     */
24
    protected $length = 0;
25
26
    public function count()
27
    {
28
        return $this->length;
29
    }
30
31
    /**
32
     * {@inheritDoc}
33
     */
34
    public function clear()
35
    {
36
        $this->values = [];
37
        $this->length = 0;
38
    }
39
40
    /**
41
     * {@inheritDoc}
42
     */
43
    public function contains($value)
44
    {
45
        return $value === null ? array_key_exists(Identity::hash(null), $this->values) : isset($this->values[Identity::hash($value)]);
46
    }
47
48
    /**
49
     * {@inheritDoc}
50
     */
51
    public function add($value)
52
    {
53
        return $this->addRef($value);
54
    }
55
56
    /**
57
     * {@inheritDoc}
58
     */
59
    public function addRef(&$value)
60
    {
61
        $identityHash = Identity::hash($value);
62
63
        if (isset($this->values[$identityHash]) || array_key_exists($identityHash, $this->values)) {
64
            return false;
65
        }
66
67
        $this->values[$identityHash] =& $value;
68
        $this->length++;
69
70
        return true;
71
    }
72
73
    /**
74
     * {@inheritDoc}
75
     */
76
    public function remove($value)
77
    {
78
        $identityHash = Identity::hash($value);
79
80
        if (!isset($this->values[$identityHash]) && !array_key_exists($identityHash, $this->values)) {
81
            return false;
82
        }
83
84
        unset($this->values[$identityHash]);
85
        $this->length--;
86
87
        return true;
88
    }
89
90
    /**
91
     * @return bool
92
     */
93
    final public function isArrayCompatible()
94
    {
95
        return true;
96
    }
97
}
98