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.

Collection   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 91.3%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 54
c 0
b 0
f 0
rs 10
ccs 21
cts 23
cp 0.913
wmc 11

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getIterator() 0 3 1
A count() 0 3 1
A get() 0 6 2
A set() 0 3 1
A select() 0 11 3
A all() 0 3 1
A has() 0 3 1
A throwNotFound() 0 3 1
1
<?php declare(strict_types=1);
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
use Countable;
11
use IteratorAggregate;
12
13
class Collection implements Countable, IteratorAggregate
14
{
15
    protected $values = [];
16
17
    public function all()
18
    {
19
        return $this->values;
20
    }
21
22 26
    public function get(string $name)
23
    {
24 26
        if ($this->has($name)) {
25 21
            return $this->values[$name];
26
        } else {
27 5
            return $this->throwNotFound($name);
28
        }
29
    }
30
31 26
    public function has(string $name): bool
32
    {
33 26
        return array_key_exists($name, $this->values);
34
    }
35
36 23
    public function set(string $name, $object)
37
    {
38 23
        $this->values[$name] = $object;
39 23
    }
40
41 2
    public function count(): int
42
    {
43 2
        return count($this->values);
44
    }
45
46 5
    public function select(callable $callback): array
47
    {
48 5
        $values = [];
49
50 5
        foreach ($this->values as $key => $value) {
51 5
            if ($callback($value, $key)) {
52 5
                $values[$key] = $value;
53
            }
54
        }
55
56 5
        return $values;
57
    }
58
59 13
    public function getIterator()
60
    {
61 13
        return new \ArrayIterator($this->values);
62
    }
63
64 1
    protected function throwNotFound(string $name)
65
    {
66 1
        throw new \InvalidArgumentException("Element \"$name\" not found in collection.");
67
    }
68
}
69