1 | <?php |
||
21 | class Cookie implements AdapterInterface |
||
22 | { |
||
23 | /** |
||
24 | * The name of cookie. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $cookieName; |
||
29 | /** |
||
30 | * The cookie's time to live in seconds |
||
31 | * |
||
32 | * @var int |
||
33 | */ |
||
34 | protected $ttl; |
||
35 | /** |
||
36 | * The array of which will be saved in cookie. |
||
37 | * |
||
38 | * @var null|array |
||
39 | */ |
||
40 | protected $data; |
||
41 | |||
42 | /** |
||
43 | * Initializes a new instance of this class. |
||
44 | * |
||
45 | * @param string $cookieName The name the cookie. |
||
46 | * @param int $ttl How long should the cookie last in browser. Default 5 years |
||
47 | * Setting a negative number will make cookie expire after current session |
||
48 | * @throws InvalidArgumentException |
||
49 | */ |
||
50 | 20 | public function __construct($cookieName, $ttl = 157766400) |
|
61 | |||
62 | /** |
||
63 | * Parses any previous cookie and stores it internally |
||
64 | */ |
||
65 | 12 | protected function parseExistingCookie() |
|
87 | |||
88 | /** |
||
89 | * {@inheritDoc} |
||
90 | */ |
||
91 | 3 | protected function saveCookie() |
|
97 | |||
98 | /** |
||
99 | * {@inheritDoc} |
||
100 | */ |
||
101 | 11 | public function has($identifier) |
|
110 | |||
111 | /** |
||
112 | * {@inheritDoc} |
||
113 | */ |
||
114 | 4 | public function get($identifier) |
|
122 | |||
123 | /** |
||
124 | * {@inheritDoc} |
||
125 | */ |
||
126 | 4 | public function set($identifier, $participation) |
|
142 | |||
143 | /** |
||
144 | * {@inheritDoc} |
||
145 | */ |
||
146 | 6 | public function all() |
|
152 | |||
153 | /** |
||
154 | * {@inheritDoc} |
||
155 | */ |
||
156 | 3 | public function remove($identifier) |
|
176 | |||
177 | /** |
||
178 | * {@inheritDoc} |
||
179 | */ |
||
180 | 2 | public function clear() |
|
193 | } |
||
194 |