Completed
Push — master ( c348e1...63401a )
by Luka
04:22
created

variables::offsetExists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Variables container
5
 *
6
 * @author    USAMI Kenta <[email protected]>
7
 * @copyright 2017 Baguette HQ
8
 * @license   https://www.gnu.org/licenses/gpl-3.0.html GPL-3.0
9
 */
10
final class variables implements \ArrayAccess
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
11
{
12
    /** @var array */
13
    private $data;
14
15
    public function __construct(array $data)
16
    {
17
        $this->data = $data;
18
    }
19
20
    /**
21
     * @param  string $offset
22
     * @param  array  $option
23
     * @return mixed
24
     */
25
    public function get($offset, array $option)
26
    {
27
        return isset($this[$offset]) ? $this[$offset] : $option['default'];
28
    }
29
30
    /**
31
     * @param  string $offset
32
     * @return bool
33
     */
34
    public function offsetExists($offset)
35
    {
36
        return array_key_exists($offset, $this->data);
37
    }
38
39
    /**
40
     * @param  string $offset
41
     * @return mixed
42
     */
43
    public function offsetGet($offset)
44
    {
45
        return $this->data[$offset];
46
    }
47
48
    /**
49
     * @param  string $offset
50
     * @param  mixed $value
51
     * @return void
52
     */
53
    public function offsetSet($offset, $value)
54
    {
55
        $this->data[$offset] = $value;
56
    }
57
58
    /**
59
     * @param mixed $offset
60
     */
61
    public function offsetUnset($offset)
62
    {
63
        unset($this->data[$offset]);
64
    }
65
}
66