ArrayAccessTrait::offsetExists()   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
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * Linna Framework.
5
 *
6
 * @author Sebastian Rapetti <[email protected]>
7
 * @copyright (c) 2018, Sebastian Rapetti
8
 * @license http://opensource.org/licenses/MIT MIT License
9
 */
10
declare(strict_types=1);
11
12
namespace Linna\Session;
13
14
/**
15
 * Array Access Trait
16
 * Provide to Session the possibility to retrive values using array notation.
17
 *
18
 * @property mixed $data Session Data
19
 */
20
trait ArrayAccessTrait
21
{
22
    /**
23
     * Check.
24
     *
25
     * @param string $offset
26
     *
27
     * @return bool
28
     */
29 2
    public function offsetExists($offset)
30
    {
31 2
        return isset($this->data[$offset]);
32
    }
33
34
    /**
35
     * Get.
36
     *
37
     * @param string $offset
38
     *
39
     * @return mixed
40
     */
41 16
    public function offsetGet($offset)
42
    {
43 16
        if (isset($this->data[$offset])) {
44 14
            return $this->data[$offset];
45
        }
46
47 6
        return false;
48
    }
49
50
    /**
51
     * Store.
52
     *
53
     * @param string $offset
54
     * @param mixed  $value
55
     *
56
     * @return void
57
     */
58 14
    public function offsetSet($offset, $value)
59
    {
60 14
        $this->data[$offset] = $value;
61 14
    }
62
63
    /**
64
     * Delete.
65
     *
66
     * @param string $offset
67
     *
68
     * @return void
69
     */
70 2
    public function offsetUnset($offset)
71
    {
72 2
        unset($this->data[$offset]);
73 2
    }
74
}
75