1 | <?php |
||
24 | class Session implements EmitterAwareInterface |
||
25 | { |
||
26 | use EmitterTrait; |
||
27 | |||
28 | /** |
||
29 | * Session manager. |
||
30 | * |
||
31 | * @var Manager |
||
32 | */ |
||
33 | protected $sessionManager; |
||
34 | |||
35 | /** |
||
36 | * Session data. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $data = []; |
||
41 | |||
42 | /** |
||
43 | * Session constructor. |
||
44 | * |
||
45 | * @param Manager $sessionManager |
||
46 | */ |
||
47 | public function __construct(Manager $sessionManager) |
||
51 | |||
52 | /** |
||
53 | * Get session manager. |
||
54 | * |
||
55 | * @return Manager |
||
56 | */ |
||
57 | public function getManager() |
||
61 | |||
62 | /** |
||
63 | * Start session. |
||
64 | * |
||
65 | * @throws \RuntimeException |
||
66 | */ |
||
67 | public function start() |
||
85 | |||
86 | /** |
||
87 | * Regenerate session identifier keeping parameters. |
||
88 | * |
||
89 | * @throws \RuntimeException |
||
90 | * |
||
91 | * @SuppressWarnings(PMD.Superglobals) |
||
92 | */ |
||
93 | public function regenerateId() |
||
105 | |||
106 | /** |
||
107 | * Close session. |
||
108 | * |
||
109 | * @SuppressWarnings(PMD.Superglobals) |
||
110 | */ |
||
111 | public function close() |
||
123 | |||
124 | /** |
||
125 | * Destroy session. |
||
126 | * |
||
127 | * @throws \RuntimeException |
||
128 | */ |
||
129 | public function destroy() |
||
143 | |||
144 | /** |
||
145 | * Is there an active session. |
||
146 | * |
||
147 | * @return bool |
||
148 | */ |
||
149 | public function isActive() : bool |
||
153 | |||
154 | /** |
||
155 | * Has session been destroyed. |
||
156 | * |
||
157 | * @return bool |
||
158 | */ |
||
159 | public function isDestroyed() : bool |
||
163 | |||
164 | /** |
||
165 | * Get session identifier. |
||
166 | * |
||
167 | * @return string |
||
168 | */ |
||
169 | public function getId() : string |
||
173 | |||
174 | /** |
||
175 | * Set session identifier. |
||
176 | * |
||
177 | * @param string $sessionId |
||
178 | * |
||
179 | * @throws \RuntimeException |
||
180 | */ |
||
181 | public function setId(string $sessionId) |
||
185 | |||
186 | /** |
||
187 | * Session parameter existence. |
||
188 | * |
||
189 | * @param string $key |
||
190 | * |
||
191 | * @return bool |
||
192 | */ |
||
193 | public function has(string $key) : bool |
||
197 | |||
198 | /** |
||
199 | * Retrieve session parameter. |
||
200 | * |
||
201 | * @param string $key |
||
202 | * @param mixed|null $default |
||
203 | * |
||
204 | * @return mixed |
||
205 | */ |
||
206 | public function get(string $key, $default = null) |
||
210 | |||
211 | /** |
||
212 | * Set session parameter. |
||
213 | * |
||
214 | * @param string $key |
||
215 | * @param mixed $value |
||
216 | * |
||
217 | * @throws \InvalidArgumentException |
||
218 | * |
||
219 | * @return static |
||
220 | */ |
||
221 | public function set(string $key, $value) : self |
||
229 | |||
230 | /** |
||
231 | * Verify only scalar values allowed. |
||
232 | * |
||
233 | * @param string|int|float|bool|array $value |
||
234 | * |
||
235 | * @throws \InvalidArgumentException |
||
236 | */ |
||
237 | final protected function verifyScalarValue($value) |
||
249 | |||
250 | /** |
||
251 | * Remove session parameter. |
||
252 | * |
||
253 | * @param string $key |
||
254 | * |
||
255 | * @return static |
||
256 | */ |
||
257 | public function remove(string $key) : self |
||
265 | |||
266 | /** |
||
267 | * Remove all session parameters. |
||
268 | * |
||
269 | * @return static |
||
270 | */ |
||
271 | public function clear() : self |
||
282 | |||
283 | /** |
||
284 | * Manage session timeout. |
||
285 | * |
||
286 | * @throws \RuntimeException |
||
287 | */ |
||
288 | protected function manageTimeout() |
||
303 | |||
304 | /** |
||
305 | * Get cookie header content. |
||
306 | * |
||
307 | * @return string |
||
308 | */ |
||
309 | public function getCookieString() : string |
||
325 | |||
326 | /** |
||
327 | * Get session cookie parameters. |
||
328 | * |
||
329 | * @param int $expireTime |
||
330 | * |
||
331 | * @return string |
||
332 | */ |
||
333 | protected function getCookieParameters(int $expireTime) : string |
||
363 | |||
364 | /** |
||
365 | * Get session configuration. |
||
366 | * |
||
367 | * @return Configuration |
||
368 | */ |
||
369 | protected function getConfiguration() : Configuration |
||
373 | } |
||
374 |