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
Pull Request — develop (#30)
by Tom Van
02:05
created

ArrayCollection::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
/**
3
 * Basic array implementation of a Collection
4
 *
5
 * @link        http://github.com/PHPExif/php-exif-common for the canonical source repository
6
 * @copyright   Copyright (c) 2016 Tom Van Herreweghe <[email protected]>
7
 * @license     http://github.com/PHPExif/php-exif-common/blob/master/LICENSE MIT License
8
 * @category    PHPExif
9
 * @package     Common
10
 * @codeCoverageIgnore
11
 */
12
13
namespace PHPExif\Common\Collection;
14
15
use PHPExif\Common\Exception\Collection\ElementAlreadyExistsException;
16
use PHPExif\Common\Exception\Collection\ElementNotExistsException;
17
18
/**
19
 * ArrayCollection class
20
 *
21
 * @category    PHPExif
22
 * @package     Common
23
 */
24
class ArrayCollection implements Collection
25
{    /**
0 ignored issues
show
Coding Style introduced by
The opening class brace should be on a newline by itself.
Loading history...
26
     * Holds the entries of the collection
27
     *
28
     * @var array
29
     */
30
    protected $elements;
31
32
    /**
33
     * Collection constructor
34
     *
35
     * @param array $elements
36
     */
37
    public function __construct(array $elements = array())
38
    {
39
        $this->elements = array();
40
41
        foreach ($elements as $name => $value) {
42
            $this->set($name, $value);
43
        }
44
    }
45
46
    /**
47
     * @inheritDoc
48
     */
49
    public function add($value)
50
    {
51
        $this->elements[] = $value;
52
53
        return $this;
54
    }
55
56
    /**
57
     * @inheritDoc
58
     */
59
    public function set($key, $value)
60
    {
61
        if ($this->exists($key)) {
62
            throw ElementAlreadyExistsException::withKey($key);
63
        }
64
65
        $this->elements[$key] = $value;
66
67
        return $this;
68
    }
69
70
    /**
71
     * @inheritDoc
72
     */
73
    public function exists($key)
74
    {
75
        return array_key_exists($key, $this->elements);
76
    }
77
78
    /**
79
     * @inheritDoc
80
     */
81
    public function get($key)
82
    {
83
        if (!$this->exists($key)) {
84
            throw ElementNotExistsException::withKey($key);
85
        }
86
87
        return $this->elements[$key];
88
    }
89
90
    /**
91
     * @inheritDoc
92
     */
93
    public function count()
94
    {
95
        return count($this->elements);
96
    }
97
98
}
99