Passed
Pull Request — master (#109)
by Romain
03:30
created

RequestedUserInfo   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 17
dl 0
loc 87
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getContactEmail() 0 3 1
A getShippingAddress() 0 3 1
A getContactPhone() 0 3 1
A getContactName() 0 3 1
A __construct() 0 10 1
A create() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\Callback\Payment;
6
7
use Kerox\Messenger\Model\Common\Address;
8
9
class RequestedUserInfo
10
{
11
    /**
12
     * @var \Kerox\Messenger\Model\Common\Address
13
     */
14
    protected $shippingAddress;
15
16
    /**
17
     * @var string
18
     */
19
    protected $contactName;
20
21
    /**
22
     * @var null|string
23
     */
24
    protected $contactEmail;
25
26
    /**
27
     * @var null|string
28
     */
29
    protected $contactPhone;
30
31
    /**
32
     * RequestedUserInfo constructor.
33
     *
34
     * @param \Kerox\Messenger\Model\Common\Address $shippingAddress
35
     * @param string                                $contactName
36
     * @param null|string                           $contactEmail
37
     * @param null|string                           $contactPhone
38
     */
39 9
    public function __construct(
40
        Address $shippingAddress,
41
        string $contactName,
42
        ?string $contactEmail = null,
43
        ?string $contactPhone = null
44
    ) {
45 9
        $this->shippingAddress = $shippingAddress;
46 9
        $this->contactName = $contactName;
47 9
        $this->contactEmail = $contactEmail;
48 9
        $this->contactPhone = $contactPhone;
49 9
    }
50
51
    /**
52
     * @return \Kerox\Messenger\Model\Common\Address
53
     */
54 4
    public function getShippingAddress(): Address
55
    {
56 4
        return $this->shippingAddress;
57
    }
58
59
    /**
60
     * @return string
61
     */
62 2
    public function getContactName(): string
63
    {
64 2
        return $this->contactName;
65
    }
66
67
    /**
68
     * @return null|string
69
     */
70 1
    public function getContactEmail(): ?string
71
    {
72 1
        return $this->contactEmail;
73
    }
74
75
    /**
76
     * @return null|string
77
     */
78 1
    public function getContactPhone(): ?string
79
    {
80 1
        return $this->contactPhone;
81
    }
82
83
    /**
84
     * @param array $callbackData
85
     *
86
     * @return \Kerox\Messenger\Model\Callback\Payment\RequestedUserInfo
87
     */
88 9
    public static function create(array $callbackData): self
89
    {
90 9
        $shippingAddress = Address::fromPayload($callbackData['shipping_address']);
91
92 9
        $contactEmail = $callbackData['contact_email'] ?? null;
93 9
        $contactPhone = $callbackData['contact_phone'] ?? null;
94
95 9
        return new self($shippingAddress, $callbackData['contact_name'], $contactEmail, $contactPhone);
96
    }
97
}
98