Completed
Push — master ( 6b086b...7ffeec )
by Łukasz
02:25
created

UpdateCustomerRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A getCommand() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sylius\ShopApiPlugin\Request;
6
7
use DateTimeInterface;
8
use Sylius\ShopApiPlugin\Command\UpdateCustomer;
9
use Symfony\Component\HttpFoundation\Request;
10
11
final class UpdateCustomerRequest
12
{
13
    /** @var string */
14
    private $firstName;
15
16
    /** @var string */
17
    private $lastName;
18
19
    /** @var string|null */
20
    private $email;
21
22
    /** @var DateTimeInterface|null */
23
    private $birthday;
24
25
    /** @var string */
26
    private $gender;
27
28
    /** @var string|null */
29
    private $phoneNumber;
30
31
    /** @var bool */
32
    private $subscribedToNewsletter;
33
34
    /**
35
     * @param Request $request
36
     */
37
    public function __construct(Request $request)
38
    {
39
        $this->firstName = $request->request->get('firstName');
40
        $this->lastName = $request->request->get('lastName');
41
        $this->email = $request->request->get('email');
42
        $this->birthday = $request->request->get('birthday');
43
        $this->gender = $request->request->get('gender');
44
        $this->phoneNumber = $request->request->get('phoneNumber');
45
        $this->subscribedToNewsletter = (bool) $request->request->get('subscribedToNewsletter') ?? false;
46
    }
47
48
    /**
49
     * @return UpdateCustomer
50
     */
51
    public function getCommand()
52
    {
53
        return new UpdateCustomer($this->firstName, $this->lastName, $this->email, $this->birthday, $this->gender, $this->phoneNumber, $this->subscribedToNewsletter);
54
    }
55
}
56