Completed
Push — master ( 02f68d...d0258d )
by Paweł
03:13
created

AddCouponRequest::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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