Total Complexity | 6 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Coverage | 58.33% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class LaravelCookie implements IdentifierInterface |
||
13 | { |
||
14 | /** |
||
15 | * Get the current or new unique identifier. |
||
16 | * |
||
17 | * @return string The identifier |
||
18 | */ |
||
19 | 4 | public function get(): string |
|
20 | { |
||
21 | 4 | if (request()->hasCookie('cart_identifier')) { |
|
22 | $cookie = request()->cookie('cart_identifier'); |
||
23 | |||
24 | if (is_string($cookie) && ! empty($cookie)) { |
||
25 | return $cookie; |
||
26 | } |
||
27 | } |
||
28 | |||
29 | 4 | return $this->regenerate(); |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * Regenerate the identifier. |
||
34 | * |
||
35 | * @return string The identifier |
||
36 | */ |
||
37 | 4 | public function regenerate(): string |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * Forget the identifier. |
||
48 | * |
||
49 | * @return void |
||
50 | */ |
||
51 | public function forget(): void |
||
54 | } |
||
55 | } |
||
56 |