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::has()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
nc 1
nop 1
dl 0
loc 3
c 0
b 0
f 0
cc 1
rs 10
ccs 2
cts 2
cp 1
crap 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