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 ( ff17e5...8a3c78 )
by Anton
02:14
created

Collection::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Collection;
9
10
class Collection implements CollectionInterface, \Countable
11
{
12
    /**
13
     * @var array
14
     */
15
    private $collection = [];
16
17
    /**
18
     * Collection constructor.
19
     * @param array $collection
20 50
     */
21
    public function __construct(array $collection = [])
22 50
    {
23 45
        $this->collection = $collection;
24
    }
25 5
26 5
    /**
27 5
     * {@inheritdoc}
28
     */
29
    public function get($name)
30
    {
31
        if ($this->has($name)) {
32
            return $this->collection[$name];
33
        } else {
34 51
            $class = explode('\\', static::class);
35
            $class = end($class);
36 51
            throw new \RuntimeException("Object `$name` does not exist in $class.");
37
        }
38
    }
39
40
    /**
41
     * {@inheritdoc}
42 46
     */
43
    public function has($name)
44 46
    {
45 46
        return array_key_exists($name, $this->collection);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50 25
     */
51
    public function set($name, $object)
52 25
    {
53
        $this->collection[$name] = $object;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58 1
     */
59
    public function getIterator()
60 1
    {
61
        return new \ArrayIterator($this->collection);
62
    }
63
64
    /**
65
     * {@inheritdoc}
66 40
     */
67
    public function offsetExists($offset)
68 40
    {
69
        return $this->has($offset);
70
    }
71
72
    /**
73
     * {@inheritdoc}
74 41
     */
75
    public function offsetGet($offset)
76 41
    {
77 41
        return $this->get($offset);
78
    }
79
80
    /**
81
     * {@inheritdoc}
82 1
     */
83
    public function offsetSet($offset, $value)
84 1
    {
85 1
        $this->set($offset, $value);
86
    }
87
88
    /**
89
     * {@inheritdoc}
90 2
     */
91
    public function offsetUnset($offset)
92 2
    {
93
        unset($this->collection[$offset]);
94
    }
95
96
    /**
97
     * {@inheritdoc}
98
     */
99
    public function count()
100
    {
101
        return count($this->collection);
102
    }
103
104
    /**
105
     * @return array
106
     */
107
    public function toArray()
108
    {
109
        return iterator_to_array($this);
110
    }
111
}
112