1 | <?php |
||
29 | class NativeSession implements Session |
||
30 | { |
||
31 | /** |
||
32 | * @var array Who told you you could eat *my* cookies?! |
||
33 | */ |
||
34 | protected $cookies = []; |
||
35 | /** |
||
36 | * @var Values[] Array of values, with string namespace as key |
||
37 | */ |
||
38 | protected $values = []; |
||
39 | /** |
||
40 | * @var \SplObjectStorage |
||
41 | */ |
||
42 | protected $plugins; |
||
43 | |||
44 | /** |
||
45 | * Creates a new native session utility. |
||
46 | * |
||
47 | * For example, to create a session with two plugins: |
||
48 | * |
||
49 | * ```php |
||
50 | * $csrf = new \Caridea\Session\CsrfPlugin(new \Caridea\Random\Mcrypt()); |
||
51 | * $flash = new \Caridea\Session\FlashPlugin(); |
||
52 | * $session = new \Caridea\Session\NativeSession($_COOKIE, [$csrf, $flash]); |
||
53 | * ``` |
||
54 | * |
||
55 | * @param array $cookies A copy of the client cookies, typically from $_COOKIE |
||
56 | * @param Plugin[] $plugins Optional array of plugins to attach to the session |
||
57 | */ |
||
58 | 13 | public function __construct(array $cookies, array $plugins = []) |
|
68 | |||
69 | /** |
||
70 | * {@inheritDoc} |
||
71 | */ |
||
72 | 1 | public function canResume(): bool |
|
76 | |||
77 | /** |
||
78 | * {@inheritDoc} |
||
79 | */ |
||
80 | 1 | public function clear(): void |
|
84 | |||
85 | /** |
||
86 | * {@inheritDoc} |
||
87 | */ |
||
88 | 3 | public function destroy(): bool |
|
109 | |||
110 | /** |
||
111 | * {@inheritDoc} |
||
112 | */ |
||
113 | 1 | public function getValues(string $namespace): Map |
|
120 | |||
121 | /** |
||
122 | * {@inheritDoc} |
||
123 | */ |
||
124 | 1 | public function isStarted(): bool |
|
128 | |||
129 | /** |
||
130 | * {@inheritDoc} |
||
131 | */ |
||
132 | 2 | public function regenerateId(): bool |
|
140 | |||
141 | /** |
||
142 | * {@inheritDoc} |
||
143 | */ |
||
144 | 3 | public function resume(): bool |
|
152 | |||
153 | /** |
||
154 | * {@inheritDoc} |
||
155 | */ |
||
156 | 2 | public function start(): bool |
|
167 | } |
||
168 |