__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Locastic\SyliusComparerPlugin\Factory;
6
7
use Locastic\SyliusComparerPlugin\Context\ComparerContextInterface;
8
use Locastic\SyliusComparerPlugin\Request\ComparerRequestInterface;
9
use Locastic\SyliusComparerPlugin\Request\RemoveProductFromComparerRequest;
10
use Symfony\Component\HttpFoundation\Request;
11
12
class RemoveProductFromComparerRequestFactory implements ComparerRequestFactoryInterface
13
{
14
    /** @var ComparerContextInterface */
15
    private $comparerContext;
16
17
    public function __construct(ComparerContextInterface $comparerContext)
18
    {
19
        $this->comparerContext = $comparerContext;
20
    }
21
22
    public function create(Request $request): ComparerRequestInterface
23
    {
24
        return new RemoveProductFromComparerRequest(
25
            $request->get('productId'),
0 ignored issues
show
Bug introduced by
It seems like $request->get('productId') can also be of type null; however, parameter $productId of Locastic\SyliusComparerP...rRequest::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

25
            /** @scrutinizer ignore-type */ $request->get('productId'),
Loading history...
26
            $this->comparerContext->getComparer($request)
0 ignored issues
show
Bug introduced by
It seems like $this->comparerContext->getComparer($request) can also be of type null; however, parameter $comparer of Locastic\SyliusComparerP...rRequest::__construct() does only seem to accept Locastic\SyliusComparerP...ntity\ComparerInterface, maybe add an additional type check? ( Ignorable by Annotation )

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

26
            /** @scrutinizer ignore-type */ $this->comparerContext->getComparer($request)
Loading history...
27
        );
28
    }
29
}
30