Conditions | 4 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
21 | public function get(): ?string |
||
22 | { |
||
23 | if (!$this->has()) return null; |
||
24 | |||
25 | try { |
||
26 | //Somehow I got this error: unserialize(): Error at offset 0 of 2 bytes |
||
27 | //I needed to change decrypt(value, unserialize = false); |
||
28 | return app('encrypter')->decrypt(request()->cookie($this->key), false); |
||
29 | } catch (DecryptException $e) { |
||
30 | //Somehow the middleware for decrypting does not kick in here... |
||
31 | //but it even fails if we use php artisan <something> (weird) |
||
32 | //if it happes we can simply give it normally back |
||
33 | return request()->cookie($this->key); |
||
|
|||
34 | } catch (\Exception $e) { |
||
35 | //So I don't return a cookie in that case |
||
36 | return null; |
||
37 | } |
||
45 |