1 | <?php |
||
10 | class Customer implements CreatableFromArray |
||
11 | { |
||
12 | /** |
||
13 | * @var int |
||
14 | */ |
||
15 | private $customerNo; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $name; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $notes; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $orgNo; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | private $vatNo; |
||
36 | |||
37 | /** |
||
38 | * @var CustomerContact |
||
39 | */ |
||
40 | private $contact; |
||
41 | |||
42 | /** |
||
43 | * @var CustomerBillingAddress |
||
44 | */ |
||
45 | private $address; |
||
46 | |||
47 | /** |
||
48 | * @var CustomerDeliveryAddress |
||
49 | */ |
||
50 | private $deliveryAddress; |
||
51 | |||
52 | /** |
||
53 | * @var \DateTime |
||
54 | */ |
||
55 | private $createdAt; |
||
56 | |||
57 | /** |
||
58 | * @var \DateTime |
||
59 | */ |
||
60 | private $updatedAt; |
||
61 | |||
62 | /** |
||
63 | * @var string |
||
64 | */ |
||
65 | private $companyType; |
||
66 | |||
67 | 4 | public function __construct() |
|
70 | |||
71 | /** |
||
72 | * @return int |
||
73 | */ |
||
74 | public function getCustomerNo() |
||
78 | |||
79 | /** |
||
80 | * @param int $customerNo |
||
81 | * |
||
82 | * @return Customer |
||
83 | */ |
||
84 | 2 | public function withCustomerNo(int $customerNo) |
|
91 | |||
92 | /** |
||
93 | * @return string |
||
94 | */ |
||
95 | public function getName() |
||
99 | |||
100 | /** |
||
101 | * @param string $name |
||
102 | * |
||
103 | * @return Customer |
||
104 | */ |
||
105 | public function withName(string $name) |
||
106 | { |
||
107 | $new = clone $this; |
||
108 | $new->name = $name; |
||
109 | |||
110 | return $new; |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * @return string |
||
115 | */ |
||
116 | public function getNotes() |
||
120 | |||
121 | /** |
||
122 | * @param string $notes |
||
123 | * |
||
124 | * @return Customer |
||
125 | */ |
||
126 | public function withNotes(string $notes) |
||
127 | { |
||
128 | $new = clone $this; |
||
129 | $new->notes = $notes; |
||
130 | |||
131 | return $new; |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * @return string |
||
136 | */ |
||
137 | public function getOrgNo() |
||
141 | |||
142 | /** |
||
143 | * @param string $orgNo |
||
144 | * |
||
145 | * @return Customer |
||
146 | */ |
||
147 | public function withOrgNo(string $orgNo) |
||
148 | { |
||
149 | $new = clone $this; |
||
150 | $new->orgNo = $orgNo; |
||
151 | |||
152 | return $new; |
||
153 | } |
||
154 | |||
155 | /** |
||
156 | * @return string |
||
157 | */ |
||
158 | public function getVatNo() |
||
162 | |||
163 | /** |
||
164 | * @param string $vatNo |
||
165 | * |
||
166 | * @return Customer |
||
167 | */ |
||
168 | public function withVatNo(string $vatNo) |
||
169 | { |
||
170 | $new = clone $this; |
||
171 | $new->vatNo = $vatNo; |
||
172 | |||
173 | return $new; |
||
174 | } |
||
175 | |||
176 | /** |
||
177 | * @return CustomerContact |
||
178 | */ |
||
179 | public function getContact() |
||
183 | |||
184 | /** |
||
185 | * @param CustomerContact $contact |
||
186 | * |
||
187 | * @return Customer |
||
188 | */ |
||
189 | public function withContact(CustomerContact $contact) |
||
190 | { |
||
191 | $new = clone $this; |
||
192 | $new->contact = $contact; |
||
193 | |||
194 | return $new; |
||
195 | } |
||
196 | |||
197 | /** |
||
198 | * @return CustomerBillingAddress |
||
199 | */ |
||
200 | public function getAddress() |
||
204 | |||
205 | /** |
||
206 | * @param CustomerBillingAddress $address |
||
207 | * |
||
208 | * @return Customer |
||
209 | */ |
||
210 | public function withAddress(CustomerBillingAddress $address) |
||
211 | { |
||
212 | $new = clone $this; |
||
213 | $new->address = $address; |
||
214 | |||
215 | return $new; |
||
216 | } |
||
217 | |||
218 | /** |
||
219 | * @return CustomerDeliveryAddress |
||
220 | */ |
||
221 | public function getDeliveryAddress() |
||
225 | |||
226 | /** |
||
227 | * @param CustomerDeliveryAddress $deliveryAddress |
||
228 | * |
||
229 | * @return Customer |
||
230 | */ |
||
231 | public function withDeliveryAddress(CustomerDeliveryAddress $deliveryAddress) |
||
232 | { |
||
233 | $new = clone $this; |
||
234 | $new->deliveryAddress = $deliveryAddress; |
||
235 | |||
236 | return $new; |
||
237 | } |
||
238 | |||
239 | /** |
||
240 | * @return string |
||
241 | */ |
||
242 | public function getCompanyType() |
||
246 | |||
247 | /** |
||
248 | * @param string $companyType |
||
249 | * |
||
250 | * @return Customer |
||
251 | */ |
||
252 | public function withCompanyType(string $companyType) |
||
253 | { |
||
254 | $new = clone $this; |
||
255 | $new->companyType = $companyType; |
||
256 | |||
257 | return $new; |
||
258 | } |
||
259 | |||
260 | /** |
||
261 | * @return \DateTime |
||
262 | */ |
||
263 | public function getCreatedAt(): \DateTime |
||
267 | |||
268 | /** |
||
269 | * @return \DateTime |
||
270 | */ |
||
271 | public function getUpdatedAt(): \DateTime |
||
275 | |||
276 | /** |
||
277 | * @param \DateTime $updatedAt |
||
278 | */ |
||
279 | public function setUpdatedAt(\DateTime $updatedAt) |
||
283 | |||
284 | 4 | public static function createFromArray(array $data): Customer |
|
285 | { |
||
286 | 4 | $customer = new self(); |
|
287 | 4 | if (array_key_exists('data', $data)) { |
|
288 | $customerArray = $data['data']; |
||
289 | $contactArray = $customerArray['contact']; |
||
290 | $addressArray = $customerArray['address']; |
||
291 | $deliveryAddressArray = $customerArray['delivery_address']; |
||
318 | |||
319 | 2 | public function toArray() |
|
349 | } |
||
350 |