Passed
Pull Request — master (#81)
by
unknown
04:01
created

WishlistCookieTokenResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 9
c 1
b 1
f 0
dl 0
loc 22
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A resolve() 0 8 2
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * You can find more information about us on https://bitbag.io and write us
7
 * an email on [email protected].
8
 */
9
10
declare(strict_types=1);
11
12
namespace BitBag\SyliusWishlistPlugin\Resolver;
13
14
use Symfony\Component\HttpFoundation\RequestStack;
15
16
final class WishlistCookieTokenResolver implements WishlistCookieTokenResolverInterface
17
{
18
    private RequestStack $requestStack;
19
20
    private string $wishlistCookieToken;
21
22
    public function __construct(
23
        RequestStack $requestStack,
24
        string $wishlistCookieToken
25
    ) {
26
        $this->requestStack = $requestStack;
27
        $this->wishlistCookieToken = $wishlistCookieToken;
28
    }
29
30
    public function resolve(): string
31
    {
32
        $wishlistCookieToken = $this->requestStack->getMasterRequest()->cookies->get($this->wishlistCookieToken);
0 ignored issues
show
Deprecated Code introduced by
The function Symfony\Component\HttpFo...ack::getMasterRequest() has been deprecated: since symfony/http-foundation 5.3, use getMainRequest() instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

32
        $wishlistCookieToken = /** @scrutinizer ignore-deprecated */ $this->requestStack->getMasterRequest()->cookies->get($this->wishlistCookieToken);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
33
34
        if (!$wishlistCookieToken) {
35
            return '';
36
        }
37
        return $wishlistCookieToken;
38
    }
39
}
40