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.

LanguageAdapter::offsetUnset()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * Language.php
4
 *
5
 * @author  Michael Pratt <[email protected]>
6
 * @link    http://www.michael-pratt.com/
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 */
12
13
namespace RelativeTime\Languages;
14
15
use \ArrayAccess;
16
use \InvalidArgumentException;
17
18
/**
19
 * Abstract class for language definitions.
20
 * It basically gives the option to use an object
21
 * as as an array.
22
 */
23
abstract class LanguageAdapter implements ArrayAccess
24
{
25
    /** @var array Array with strings */
26
    protected $strings = array();
27
28
    /**
29
     * Sets a parameter
30
     *
31
     * @param string $id
32
     * @param string $value
33
     */
34 2
    public function offsetSet($id, $value)
35
    {
36 2
        $this->strings[$id] = $value;
37 2
    }
38
39
    /**
40
     * Gets a parameter
41
     *
42
     * @param string $id
43
     * @return string
44
     *
45
     * @throws InvalidArgumentException if the id is not defined
46
     */
47 24
    public function offsetGet($id)
48
    {
49 24
        if (!array_key_exists($id, $this->strings)) {
50 2
            throw new InvalidArgumentException($id . ' is not defined');
51
        }
52
53 22
        return $this->strings[$id];
54
    }
55
56
    /**
57
     * Checks if a parameter is set.
58
     *
59
     * @param string $id
60
     * @return bool
61
     */
62 4
    public function offsetExists($id)
63
    {
64 4
        return array_key_exists($id, $this->strings);
65
    }
66
67
    /**
68
     * Unsets a parameter
69
     *
70
     * @param string $id
71
     * @return void
72
     */
73 2
    public function offsetUnset($id)
74
    {
75 2
        unset($this->strings[$id]);
76 2
    }
77
78
    /**
79
     * Returns all defined keys
80
     *
81
     * @return array
82
     */
83 2
    public function keys()
84
    {
85 2
        return array_keys($this->strings);
86
    }
87
}
88
89
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
90