Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
AbstractSession | |
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
kill | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
setTimedValue | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
setRequestValue | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
count | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getIterator | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
toArray | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
__get | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
__set | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
__isset | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
__unset | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
offsetSet | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
offsetGet | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
offsetExists | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
offsetUnset | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Session; |
15 | |
16 | use ArrayAccess; |
17 | use ArrayIterator; |
18 | use Countable; |
19 | use IteratorAggregate; |
20 | |
21 | /** |
22 | * Abstract session class |
23 | * |
24 | * @category Pop |
25 | * @package Pop\Session |
26 | * @author Nick Sagona, III <dev@nolainteractive.com> |
27 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
28 | * @license http://www.popphp.org/license New BSD License |
29 | * @version 4.0.0 |
30 | */ |
31 | abstract class AbstractSession implements SessionInterface, ArrayAccess, Countable, IteratorAggregate |
32 | { |
33 | |
34 | /** |
35 | * Destroy the session |
36 | * |
37 | * @return void |
38 | */ |
39 | abstract public function kill(): void; |
40 | |
41 | /** |
42 | * Set a time-based value |
43 | * |
44 | * @param string $key |
45 | * @param mixed $value |
46 | * @param int $expire |
47 | * @return AbstractSession |
48 | */ |
49 | abstract public function setTimedValue(string $key, mixed $value, int $expire = 300): AbstractSession; |
50 | |
51 | /** |
52 | * Set a request-based value |
53 | * |
54 | * @param string $key |
55 | * @param mixed $value |
56 | * @param int $hops |
57 | * @return AbstractSession |
58 | */ |
59 | abstract public function setRequestValue(string $key, mixed $value, int $hops = 1): AbstractSession; |
60 | |
61 | /** |
62 | * Method to get the count of data in the session |
63 | * |
64 | * @return int |
65 | */ |
66 | public function count(): int |
67 | { |
68 | |
69 | return count($this->toArray()); |
70 | } |
71 | |
72 | /** |
73 | * Method to iterate over the session |
74 | * |
75 | * @return ArrayIterator |
76 | */ |
77 | public function getIterator(): ArrayIterator |
78 | { |
79 | return new ArrayIterator($this->toArray()); |
80 | } |
81 | |
82 | /** |
83 | * Get the session values as an array |
84 | * |
85 | * @return array |
86 | */ |
87 | abstract public function toArray(): array; |
88 | |
89 | /** |
90 | * Magic get method to return the value of values[$name]. |
91 | * |
92 | * @param string $name |
93 | * @return mixed |
94 | */ |
95 | abstract public function __get(string $name): mixed; |
96 | |
97 | /** |
98 | * Magic set method to set values[$name]. |
99 | * |
100 | * @param string $name |
101 | * @param mixed $value |
102 | * @return void |
103 | */ |
104 | abstract public function __set(string $name, mixed $value): void; |
105 | |
106 | /** |
107 | * Return the isset value of values[$name]. |
108 | * |
109 | * @param string $name |
110 | * @return bool |
111 | */ |
112 | abstract public function __isset(string $name): bool; |
113 | |
114 | /** |
115 | * Unset values[$name]. |
116 | * |
117 | * @param string $name |
118 | * @return void |
119 | */ |
120 | abstract public function __unset(string $name): void; |
121 | |
122 | /** |
123 | * ArrayAccess offsetSet |
124 | * |
125 | * @param mixed $offset |
126 | * @param mixed $value |
127 | * @return void |
128 | */ |
129 | public function offsetSet(mixed $offset, mixed $value): void |
130 | { |
131 | $this->__set($offset, $value); |
132 | } |
133 | |
134 | /** |
135 | * ArrayAccess offsetGet |
136 | * |
137 | * @param mixed $offset |
138 | * @return mixed |
139 | */ |
140 | public function offsetGet(mixed $offset): mixed |
141 | { |
142 | return $this->__get($offset); |
143 | } |
144 | |
145 | /** |
146 | * ArrayAccess offsetExists |
147 | * |
148 | * @param mixed $offset |
149 | * @return bool |
150 | */ |
151 | public function offsetExists(mixed $offset): bool |
152 | { |
153 | return $this->__isset($offset); |
154 | } |
155 | |
156 | /** |
157 | * ArrayAccess offsetUnset |
158 | * |
159 | * @param mixed $offset |
160 | * @return void |
161 | */ |
162 | public function offsetUnset(mixed $offset): void |
163 | { |
164 | $this->__unset($offset); |
165 | } |
166 | |
167 | } |