@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * THE SOFTWARE. |
21 | 21 | */ |
22 | 22 | |
23 | -abstract class AbstractCookie implements CookieInterface { |
|
23 | +abstract class AbstractCookie implements CookieInterface { |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * The cookie name |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @throws CookieException |
90 | 90 | */ |
91 | - public function __construct($name, $max_cookie_size = null) { |
|
91 | + public function __construct($name, $max_cookie_size = null) { |
|
92 | 92 | |
93 | - try { |
|
93 | + try { |
|
94 | 94 | |
95 | 95 | $this->setName($name); |
96 | 96 | |
97 | - } catch (CookieException $ce) { |
|
97 | + } catch (CookieException $ce) { |
|
98 | 98 | |
99 | 99 | throw $ce; |
100 | 100 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | /** |
112 | 112 | * {@inheritdoc} |
113 | 113 | */ |
114 | - public function setName($name) { |
|
114 | + public function setName($name) { |
|
115 | 115 | |
116 | 116 | if ( empty($name) || !is_scalar($name) ) throw new CookieException("Invalid cookie name"); |
117 | 117 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | /** |
125 | 125 | * {@inheritdoc} |
126 | 126 | */ |
127 | - public function getName() { |
|
127 | + public function getName() { |
|
128 | 128 | |
129 | 129 | return $this->name; |
130 | 130 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | /** |
144 | 144 | * {@inheritdoc} |
145 | 145 | */ |
146 | - public function setExpire($timestamp) { |
|
146 | + public function setExpire($timestamp) { |
|
147 | 147 | |
148 | 148 | if ( !is_int($timestamp) ) throw new CookieException("Invalud cookie's expiration time"); |
149 | 149 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | /** |
157 | 157 | * {@inheritdoc} |
158 | 158 | */ |
159 | - public function setPath($location) { |
|
159 | + public function setPath($location) { |
|
160 | 160 | |
161 | 161 | if ( !is_string($location) ) throw new CookieException("Invalid path attribute"); |
162 | 162 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | /** |
170 | 170 | * {@inheritdoc} |
171 | 171 | */ |
172 | - public function setDomain($domain) { |
|
172 | + public function setDomain($domain) { |
|
173 | 173 | |
174 | 174 | if ( !is_scalar($domain) || !CookieTools::checkDomain($domain) ) throw new CookieException("Invalid domain attribute"); |
175 | 175 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | /** |
183 | 183 | * {@inheritdoc} |
184 | 184 | */ |
185 | - public function setSecure($mode = true) { |
|
185 | + public function setSecure($mode = true) { |
|
186 | 186 | |
187 | 187 | $this->secure = filter_var($mode, FILTER_VALIDATE_BOOLEAN); |
188 | 188 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | /** |
194 | 194 | * {@inheritdoc} |
195 | 195 | */ |
196 | - public function setHttponly($mode = true) { |
|
196 | + public function setHttponly($mode = true) { |
|
197 | 197 | |
198 | 198 | $this->httponly = filter_var($mode, FILTER_VALIDATE_BOOLEAN); |
199 | 199 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | /** |
205 | 205 | * {@inheritdoc} |
206 | 206 | */ |
207 | - public function save() { |
|
207 | + public function save() { |
|
208 | 208 | |
209 | 209 | if ( setcookie( |
210 | 210 | $this->name, |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | /** |
224 | 224 | * {@inheritdoc} |
225 | 225 | */ |
226 | - public function load() { |
|
226 | + public function load() { |
|
227 | 227 | |
228 | 228 | if ( !$this->exists() ) throw new CookieException("Cookie does not exists"); |
229 | 229 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | /** |
237 | 237 | * {@inheritdoc} |
238 | 238 | */ |
239 | - public function delete() { |
|
239 | + public function delete() { |
|
240 | 240 | |
241 | 241 | if ( !$this->exists() ) return true; |
242 | 242 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | /** |
258 | 258 | * {@inheritdoc} |
259 | 259 | */ |
260 | - public function exists() { |
|
260 | + public function exists() { |
|
261 | 261 | |
262 | 262 | return isset($_COOKIE[$this->name]); |
263 | 263 | |
@@ -272,9 +272,9 @@ discard block |
||
272 | 272 | * @return boolean |
273 | 273 | * @throws CookieException |
274 | 274 | */ |
275 | - public static function erase($name) { |
|
275 | + public static function erase($name) { |
|
276 | 276 | |
277 | - try { |
|
277 | + try { |
|
278 | 278 | |
279 | 279 | $class = get_called_class(); |
280 | 280 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | return $cookie->delete(); |
284 | 284 | |
285 | - } catch (CookieException $ce) { |
|
285 | + } catch (CookieException $ce) { |
|
286 | 286 | |
287 | 287 | throw $ce; |
288 | 288 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * THE SOFTWARE. |
22 | 22 | */ |
23 | 23 | |
24 | -class EncryptedCookie extends AbstractCookie { |
|
24 | +class EncryptedCookie extends AbstractCookie { |
|
25 | 25 | |
26 | 26 | /* |
27 | 27 | * AES key |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @throws CookieException |
43 | 43 | */ |
44 | - public function __construct($name, $key, $max_cookie_size = null) { |
|
44 | + public function __construct($name, $key, $max_cookie_size = null) { |
|
45 | 45 | |
46 | 46 | if ( empty($key) OR !is_scalar($key) ) throw new CookieException("Invalid secret key"); |
47 | 47 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * {@inheritdoc} |
54 | 54 | */ |
55 | - public function setValue($value, $serialize = true) { |
|
55 | + public function setValue($value, $serialize = true) { |
|
56 | 56 | |
57 | 57 | if ( !is_scalar($value) && $serialize === false ) throw new CookieException("Cannot set non-scalar value without serialization"); |
58 | 58 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * {@inheritdoc} |
81 | 81 | */ |
82 | - public function getValue($unserialize = true) { |
|
82 | + public function getValue($unserialize = true) { |
|
83 | 83 | |
84 | 84 | $cipher = new AES(AES::MODE_ECB); |
85 | 85 | |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | * @return EncryptedCookie |
116 | 116 | * @throws CookieException |
117 | 117 | */ |
118 | - public static function create($name, $key, array $properties = [], $serialize = true) { |
|
118 | + public static function create($name, $key, array $properties = [], $serialize = true) { |
|
119 | 119 | |
120 | - try { |
|
120 | + try { |
|
121 | 121 | |
122 | 122 | $class = get_called_class(); |
123 | 123 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | CookieTools::setCookieProperties($cookie, $properties, $serialize); |
127 | 127 | |
128 | - } catch (CookieException $ce) { |
|
128 | + } catch (CookieException $ce) { |
|
129 | 129 | |
130 | 130 | throw $ce; |
131 | 131 | |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | * @return EncryptedCookie |
147 | 147 | * @throws CookieException |
148 | 148 | */ |
149 | - public static function retrieve($name, $key) { |
|
149 | + public static function retrieve($name, $key) { |
|
150 | 150 | |
151 | - try { |
|
151 | + try { |
|
152 | 152 | |
153 | 153 | $class = get_called_class(); |
154 | 154 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | $return = $cookie->load(); |
158 | 158 | |
159 | - } catch (CookieException $ce) { |
|
159 | + } catch (CookieException $ce) { |
|
160 | 160 | |
161 | 161 | throw $ce; |
162 | 162 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return string |
175 | 175 | */ |
176 | - protected static function encryptKey($key) { |
|
176 | + protected static function encryptKey($key) { |
|
177 | 177 | |
178 | 178 | return hash('sha256', $key); |
179 | 179 |