Completed
Pull Request — master (#12)
by Romain
06:58
created

RequestedUserInfo   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 82
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

6 Methods

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