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.

ArrayAccessTrait::offsetExists()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
3
namespace OpenStack\Common;
4
5
/**
6
 * Encapsulates common logic for classes which implement the SPL \ArrayAccess interface.
7
 *
8
 * @package OpenStack\Common
9
 */
10
trait ArrayAccessTrait
11
{
12
    /**
13
     * The internal state that this object represents
14
     *
15
     * @var array
16
     */
17
    private $internalState = [];
18
19
    /**
20
     * Sets an internal key with a value.
21
     *
22
     * @param string $offset
23
     * @param mixed  $value
24
     */
25 5
    public function offsetSet($offset, $value)
26
    {
27 5
        if (null === $offset) {
28 1
            $this->internalState[] = $value;
29 1
        } else {
30 4
            $this->internalState[$offset] = $value;
31
        }
32 5
    }
33
34
    /**
35
     * Checks whether an internal key exists.
36
     *
37
     * @param string $offset
38
     *
39
     * @return bool
40
     */
41 3
    public function offsetExists(string $offset): bool
42
    {
43 3
        return isset($this->internalState[$offset]);
44
    }
45
46
    /**
47
     * Unsets an internal key.
48
     *
49
     * @param string $offset
50
     */
51 1
    public function offsetUnset(string $offset)
52
    {
53 1
        unset($this->internalState[$offset]);
54 1
    }
55
56
    /**
57
     * Retrieves an internal key.
58
     *
59
     * @param string $offset
60
     *
61
     * @return mixed|null
62
     */
63 2
    public function offsetGet(string $offset)
64
    {
65 2
        return $this->offsetExists($offset) ? $this->internalState[$offset] : null;
66
    }
67
}
68