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 | * Start session. |
||
54 | * |
||
55 | * @throws \RuntimeException |
||
56 | */ |
||
57 | public function start() |
||
71 | |||
72 | /** |
||
73 | * Regenerate session identifier keeping parameters. |
||
74 | * |
||
75 | * @throws \RuntimeException |
||
76 | * |
||
77 | * @SuppressWarnings(PMD.Superglobals) |
||
78 | */ |
||
79 | public function regenerateId() |
||
87 | |||
88 | /** |
||
89 | * Close session. |
||
90 | * |
||
91 | * @SuppressWarnings(PMD.Superglobals) |
||
92 | */ |
||
93 | public function close() |
||
101 | |||
102 | /** |
||
103 | * Destroy session. |
||
104 | * |
||
105 | * @throws \RuntimeException |
||
106 | */ |
||
107 | public function destroy() |
||
117 | |||
118 | /** |
||
119 | * Is there an active session. |
||
120 | * |
||
121 | * @return bool |
||
122 | */ |
||
123 | public function isActive() : bool |
||
127 | |||
128 | /** |
||
129 | * Get session identifier. |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | public function getId() : string |
||
137 | |||
138 | /** |
||
139 | * Session parameter existence. |
||
140 | * |
||
141 | * @param string $key |
||
142 | * |
||
143 | * @return bool |
||
144 | */ |
||
145 | public function has(string $key) : bool |
||
149 | |||
150 | /** |
||
151 | * Retrieve session parameter. |
||
152 | * |
||
153 | * @param string $key |
||
154 | * @param mixed|null $default |
||
155 | * |
||
156 | * @return mixed |
||
157 | */ |
||
158 | public function get(string $key, $default = null) |
||
162 | |||
163 | /** |
||
164 | * Set session parameter. |
||
165 | * |
||
166 | * @param string $key |
||
167 | * @param mixed $value |
||
168 | * |
||
169 | * @return static |
||
170 | */ |
||
171 | public function set(string $key, $value) : self |
||
177 | |||
178 | /** |
||
179 | * Remove session parameter. |
||
180 | * |
||
181 | * @param string $key |
||
182 | * |
||
183 | * @return static |
||
184 | */ |
||
185 | public function remove(string $key) : self |
||
193 | |||
194 | /** |
||
195 | * Remove all session parameters. |
||
196 | * |
||
197 | * @return static |
||
198 | */ |
||
199 | public function clear() |
||
207 | |||
208 | /** |
||
209 | * Get session timeout time. |
||
210 | * |
||
211 | * @return int |
||
212 | */ |
||
213 | public function getTimeout() : int |
||
217 | |||
218 | /** |
||
219 | * Set session timeout time. |
||
220 | * |
||
221 | * @return static |
||
222 | */ |
||
223 | protected function setTimeout() : self |
||
229 | |||
230 | /** |
||
231 | * Manage session timeout. |
||
232 | * |
||
233 | * @throws \RuntimeException |
||
234 | */ |
||
235 | protected function manageTimeout() |
||
249 | |||
250 | /** |
||
251 | * Get session configuration. |
||
252 | * |
||
253 | * @return Configuration |
||
254 | */ |
||
255 | protected function getConfiguration() : Configuration |
||
259 | } |
||
260 |