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.
Passed
Push — master ( b3cd52...71bd8a )
by Anton
02:19
created

Collection   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 82.61%

Importance

Changes 0
Metric Value
dl 0
loc 56
ccs 19
cts 23
cp 0.8261
rs 10
c 0
b 0
f 0
wmc 11
lcom 1
cbo 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 8 2
A has() 0 4 1
A set() 0 4 1
A count() 0 4 1
A select() 0 12 3
A throwNotFound() 0 4 1
A all() 0 4 1
A getIterator() 0 4 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 14
    public function get(string $name)
23
    {
24 14
        if ($this->has($name)) {
25 9
            return $this->values[$name];
26
        } else {
27 5
            return $this->throwNotFound($name);
28
        }
29
    }
30
31 14
    public function has(string $name): bool
32
    {
33 14
        return array_key_exists($name, $this->values);
34
    }
35
36 16
    public function set(string $name, $object)
37
    {
38 16
        $this->values[$name] = $object;
39 16
    }
40
41
    public function count(): int
42
    {
43
        return count($this->values);
44
    }
45
46 3
    public function select(callable $callback): array
47
    {
48 3
        $values = [];
49
50 3
        foreach ($this->values as $key => $value) {
51 3
            if ($callback($value, $key)) {
52 3
                $values[$key] = $value;
53
            }
54
        }
55
56 3
        return $values;
57
    }
58
59 1
    public function getIterator()
60
    {
61 1
        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