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

PutSimpleItemToCartRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 35
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getCommand() 0 4 1
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