Completed
Pull Request — master (#132)
by Łukasz
04:54
created

PutSimpleItemToCartRequest::getCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Sylius\ShopApiPlugin\Request;
4
5
use Sylius\ShopApiPlugin\Command\PutSimpleItemToCart;
6
use Symfony\Component\HttpFoundation\Request;
7
8
final class PutSimpleItemToCartRequest
9
{
10
    /**
11
     * @var string
12
     */
13
    private $token;
14
15
    /**
16
     * @var string
17
     */
18
    private $product;
19
20
    /**
21
     * @var int
22
     */
23
    private $quantity;
24
25
    /**
26
     * @param Request $request
27
     */
28
    public function __construct(Request $request)
29
    {
30
        $this->token = $request->attributes->get('token');
31
        $this->product = $request->request->get('productCode');
32
        $this->quantity = $request->request->getInt('quantity');
33
    }
34
35
    /**
36
     * @return PutSimpleItemToCart
37
     */
38
    public function getCommand()
39
    {
40
        return new PutSimpleItemToCart($this->token, $this->product, $this->quantity);
41
    }
42
}
43