1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BPCI\SumUp\Customer; |
4
|
|
|
|
5
|
|
|
class Customer implements CustomerInterface |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Customer SumUp ID |
9
|
|
|
* |
10
|
|
|
* @var string |
11
|
|
|
*/ |
12
|
|
|
protected $customerId; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Customer Name |
16
|
|
|
* |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
protected $name; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Customer phone |
23
|
|
|
* |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
protected $phone; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Cusomter address |
30
|
|
|
* |
31
|
|
|
* @var AddressInterface |
32
|
|
|
*/ |
33
|
|
|
protected $address; |
34
|
|
|
|
35
|
6 |
|
public function __construct(?array $data = []) |
36
|
|
|
{ |
37
|
6 |
|
$this->setCustomerId($data['customer_id']??null); |
38
|
6 |
|
$personal_details = $data['personal_details']??$data; |
39
|
6 |
|
$this->setName($personal_details['name']??null); |
40
|
6 |
|
$this->setPhone($personal_details['phone']??null); |
41
|
6 |
|
$this->setAddress(new Address($personal_details['address']??null)); |
42
|
6 |
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Get customer SumUp ID |
46
|
|
|
* |
47
|
|
|
* @return string |
48
|
|
|
*/ |
49
|
3 |
|
public function getCustomerId(): ?string |
50
|
|
|
{ |
51
|
3 |
|
return $this->customerId; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Set customer SumUp ID |
56
|
|
|
* |
57
|
|
|
* @param string $customerId Customer SumUp ID |
58
|
|
|
* @return CustomerInterface |
59
|
|
|
*/ |
60
|
6 |
|
public function setCustomerId(?string $customerId): CustomerInterface |
61
|
|
|
{ |
62
|
6 |
|
$this->customerId = $customerId; |
63
|
|
|
|
64
|
6 |
|
return $this; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Get customer Name |
69
|
|
|
* |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
1 |
|
public function getName(): ?string |
73
|
|
|
{ |
74
|
1 |
|
return $this->name; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Set customer Name |
79
|
|
|
* |
80
|
|
|
* @param string $name Customer Name |
81
|
|
|
* @return Customer|CustomerInterface |
82
|
|
|
*/ |
83
|
6 |
|
public function setName(?string $name): CustomerInterface |
84
|
|
|
{ |
85
|
6 |
|
$this->name = $name; |
86
|
|
|
|
87
|
6 |
|
return $this; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Get customer phone |
92
|
|
|
* |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
1 |
|
public function getPhone(): ?string |
96
|
|
|
{ |
97
|
1 |
|
return $this->phone; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Set customer phone |
102
|
|
|
* |
103
|
|
|
* @param string $phone Customer phone |
104
|
|
|
* @return Customer|CustomerInterface |
105
|
|
|
*/ |
106
|
6 |
|
public function setPhone(?string $phone): CustomerInterface |
107
|
|
|
{ |
108
|
6 |
|
$this->phone = $phone; |
109
|
|
|
|
110
|
6 |
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Get cusomter address |
115
|
|
|
* |
116
|
|
|
* @return AddressInterface |
117
|
|
|
*/ |
118
|
1 |
|
public function getAddress(): AddressInterface |
119
|
|
|
{ |
120
|
1 |
|
return $this->address; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Set cusomter address |
125
|
|
|
* |
126
|
|
|
* @param AddressInterface $address |
127
|
|
|
* @return Customer|CustomerInterface |
128
|
|
|
*/ |
129
|
6 |
|
public function setAddress(AddressInterface $address): CustomerInterface |
130
|
|
|
{ |
131
|
6 |
|
$this->address = $address; |
132
|
6 |
|
return $this; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
} |
136
|
|
|
|