RemoveProductFromComparerRequestFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 5 1
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