1 | <?php |
||
5 | class CookieStore implements Store |
||
6 | { |
||
7 | /** |
||
8 | * {@inheritdoc} |
||
9 | */ |
||
10 | public function get($cartId) |
||
14 | |||
15 | /** |
||
16 | * {@inheritdoc} |
||
17 | */ |
||
18 | public function put($cartId, $data) |
||
22 | |||
23 | /** |
||
24 | * {@inheritdoc} |
||
25 | */ |
||
26 | public function flush($cartId) |
||
30 | |||
31 | /** |
||
32 | * Encode data to be saved in cookie. |
||
33 | * |
||
34 | * @param string $data |
||
35 | * |
||
36 | * @return string |
||
37 | */ |
||
38 | 1 | public function encode($data) |
|
42 | |||
43 | /** |
||
44 | * Decode data that has been saved in a cookie. |
||
45 | * |
||
46 | * @param string $data |
||
47 | * |
||
48 | * @return string |
||
49 | */ |
||
50 | 1 | public function decode($data) |
|
54 | |||
55 | /** |
||
56 | * Set cookie. |
||
57 | * |
||
58 | * @param string $name |
||
59 | * @param string $data |
||
60 | */ |
||
61 | private function setCookie($name, $data) |
||
65 | |||
66 | /** |
||
67 | * Unset cookie. |
||
68 | * |
||
69 | * @param string $name |
||
70 | */ |
||
71 | private function unsetCookie($name) |
||
75 | } |
||
76 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: