Failed Conditions
Pull Request — master (#234)
by
unknown
02:35
created

UpdateCustomerRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 59
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
    /**
14
     * @var string
15
     */
16
    private $firstName;
17
18
    /**
19
     * @var string
20
     */
21
    private $lastName;
22
23
    /**
24
     * @var string|null
25
     */
26
    private $email;
27
28
    /**
29
     * @var DateTimeInterface|null
30
     */
31
    private $birthday;
32
33
    /**
34
     * @var string
35
     */
36
    private $gender;
37
38
    /**
39
     * @var string|null
40
     */
41
    private $phoneNumber;
42
43
    /**
44
     * @var bool
45
     */
46
    private $subscribedToNewsletter;
47
48
    /**
49
     * @param Request $request
50
     */
51
    public function __construct(Request $request)
52
    {
53
        $this->firstName = $request->request->get('firstName');
54
        $this->lastName = $request->request->get('lastName');
55
        $this->email = $request->request->get('email');
56
        $this->birthday = $request->request->get('birthday');
57
        $this->gender = $request->request->get('gender');
58
        $this->phoneNumber = $request->request->get('phoneNumber');
59
        $this->subscribedToNewsletter = (bool) $request->request->get('subscribedToNewsletter') ?? false;
60
    }
61
62
    /**
63
     * @return UpdateCustomer
64
     */
65
    public function getCommand()
66
    {
67
        return new UpdateCustomer($this->firstName, $this->lastName, $this->email, $this->birthday, $this->gender, $this->phoneNumber, $this->subscribedToNewsletter);
68
    }
69
}
70