1 | <?php |
||
19 | class Cookie |
||
20 | { |
||
21 | |||
22 | const ISSUER = 'zortje/mvc'; |
||
23 | |||
24 | /** |
||
25 | * @var Configuration |
||
26 | */ |
||
27 | protected $configuration; |
||
28 | |||
29 | /** |
||
30 | * @var string[] Internal cookie values |
||
31 | */ |
||
32 | protected $values = []; |
||
33 | |||
34 | /** |
||
35 | * Cookie constructor. |
||
36 | * |
||
37 | * @param Configuration $configuration Configuration |
||
38 | * @param string $token JWT string |
||
39 | */ |
||
40 | public function __construct(Configuration $configuration, string $token = '') |
||
45 | |||
46 | /** |
||
47 | * Set value in cookie |
||
48 | * |
||
49 | * @param string $key Cookie key |
||
50 | * @param string $value Cookie value |
||
51 | */ |
||
52 | public function set(string $key, string $value) |
||
56 | |||
57 | /** |
||
58 | * Check if value for key exists in cookie |
||
59 | * |
||
60 | * @param string $key Cookie key |
||
61 | * |
||
62 | * @return bool TRUE if key exists, otherwise FALSE |
||
63 | */ |
||
64 | public function exists(string $key) |
||
68 | |||
69 | /** |
||
70 | * Remove value for key in cookie |
||
71 | * |
||
72 | * @param string $key Cookie key |
||
73 | */ |
||
74 | public function remove(string $key) |
||
78 | |||
79 | /** |
||
80 | * Get value from cookie |
||
81 | * |
||
82 | * @param string $key Cookie key |
||
83 | * |
||
84 | * @return string Cookie value |
||
85 | * |
||
86 | * @throws CookieUndefinedIndexException |
||
87 | */ |
||
88 | public function get(string $key): string |
||
96 | |||
97 | /** |
||
98 | * @return string JWT string |
||
99 | */ |
||
100 | public function getTokenString(): string |
||
122 | |||
123 | /** |
||
124 | * Validates token for cookie and returns values if valid |
||
125 | * |
||
126 | * @param string $token |
||
127 | * |
||
128 | * @return array |
||
129 | */ |
||
130 | protected function parseAndValidateToken(string $token) |
||
163 | } |
||
164 |