Failed Conditions
Pull Request — master (#132)
by Łukasz
03:03
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 7
loc 7
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Sylius\ShopApiPlugin\Request;
4
5
use Sylius\ShopApiPlugin\Command\PutOptionBasedConfigurableItemToCart;
6
use Symfony\Component\HttpFoundation\Request;
7
8 View Code Duplication
final class PutOptionBasedConfigurableItemToCartRequest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * @var string
12
     */
13
    private $token;
14
15
    /**
16
     * @var string
17
     */
18
    private $product;
19
20
    /**
21
     * @var array
22
     */
23
    private $options;
24
25
    /**
26
     * @var int
27
     */
28
    private $quantity;
29
30
    /**
31
     * @param Request $request
32
     */
33
    public function __construct(Request $request)
34
    {
35
        $this->token = $request->attributes->get('token');
36
        $this->product = $request->request->get('productCode');
37
        $this->options = $request->request->get('options');
0 ignored issues
show
Documentation Bug introduced by
It seems like $request->request->get('options') of type * is incompatible with the declared type array of property $options.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
38
        $this->quantity = $request->request->getInt('quantity');
39
    }
40
41
    /**
42
     * @return PutOptionBasedConfigurableItemToCart
43
     */
44
    public function getCommand()
45
    {
46
        return new PutOptionBasedConfigurableItemToCart($this->token, $this->product, $this->options, $this->quantity);
47
    }
48
}
49