RequestedUserInfo::getContactEmail()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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 string|null
23
     */
24
    protected $contactEmail;
25
26
    /**
27
     * @var string|null
28
     */
29
    protected $contactPhone;
30
31
    /**
32
     * RequestedUserInfo constructor.
33
     */
34 2
    public function __construct(
35
        Address $shippingAddress,
36
        string $contactName,
37
        ?string $contactEmail = null,
38
        ?string $contactPhone = null
39
    ) {
40 2
        $this->shippingAddress = $shippingAddress;
41 2
        $this->contactName = $contactName;
42 2
        $this->contactEmail = $contactEmail;
43 2
        $this->contactPhone = $contactPhone;
44 2
    }
45
46 2
    public function getShippingAddress(): Address
47
    {
48 2
        return $this->shippingAddress;
49
    }
50
51 2
    public function getContactName(): string
52
    {
53 2
        return $this->contactName;
54
    }
55
56 1
    public function getContactEmail(): ?string
57
    {
58 1
        return $this->contactEmail;
59
    }
60
61 1
    public function getContactPhone(): ?string
62
    {
63 1
        return $this->contactPhone;
64
    }
65
66
    /**
67
     * @return \Kerox\Messenger\Model\Callback\Payment\RequestedUserInfo
68
     */
69 2
    public static function create(array $callbackData): self
70
    {
71 2
        $shippingAddress = Address::fromPayload($callbackData['shipping_address']);
72
73 2
        $contactEmail = $callbackData['contact_email'] ?? null;
74 2
        $contactPhone = $callbackData['contact_phone'] ?? null;
75
76 2
        return new self($shippingAddress, $callbackData['contact_name'], $contactEmail, $contactPhone);
77
    }
78
}
79