|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Inspirum\Balikobot\Model\Values; |
|
4
|
|
|
|
|
5
|
|
|
class PostCode |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* @var string |
|
9
|
|
|
*/ |
|
10
|
|
|
private $shipper; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @var string|null |
|
14
|
|
|
*/ |
|
15
|
|
|
private $service; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var string |
|
19
|
|
|
*/ |
|
20
|
|
|
private $postcode; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var string|null |
|
24
|
|
|
*/ |
|
25
|
|
|
private $postcodeEnd; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var string|null |
|
29
|
|
|
*/ |
|
30
|
|
|
private $city; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var string|null |
|
34
|
|
|
*/ |
|
35
|
|
|
private $country; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var bool |
|
39
|
|
|
*/ |
|
40
|
|
|
private $morningDelivery; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Postcode constructor |
|
44
|
|
|
* |
|
45
|
|
|
* @param string $shipper |
|
46
|
|
|
* @param string|null $service |
|
47
|
|
|
* @param string $postcode |
|
48
|
|
|
* @param string|null $postcodeEnd |
|
49
|
|
|
* @param string|null $city |
|
50
|
|
|
* @param string|null $country |
|
51
|
|
|
* @param bool $morningDelivery |
|
52
|
|
|
*/ |
|
53
|
4 |
|
public function __construct( |
|
54
|
|
|
string $shipper, |
|
55
|
|
|
?string $service, |
|
56
|
|
|
string $postcode, |
|
57
|
|
|
?string $postcodeEnd, |
|
58
|
|
|
?string $city, |
|
59
|
|
|
?string $country, |
|
60
|
|
|
bool $morningDelivery |
|
61
|
|
|
) { |
|
62
|
4 |
|
$this->shipper = $shipper; |
|
63
|
4 |
|
$this->service = $service; |
|
64
|
4 |
|
$this->postcode = $postcode; |
|
65
|
4 |
|
$this->postcodeEnd = $postcodeEnd; |
|
66
|
4 |
|
$this->city = $city; |
|
67
|
4 |
|
$this->country = $country; |
|
68
|
4 |
|
$this->morningDelivery = $morningDelivery; |
|
69
|
4 |
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return string |
|
73
|
|
|
*/ |
|
74
|
2 |
|
public function getShipper(): string |
|
75
|
|
|
{ |
|
76
|
2 |
|
return $this->shipper; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @return string|null |
|
81
|
|
|
*/ |
|
82
|
2 |
|
public function getService(): ?string |
|
83
|
|
|
{ |
|
84
|
2 |
|
return $this->service; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @return string |
|
89
|
|
|
*/ |
|
90
|
4 |
|
public function getPostcode(): string |
|
91
|
|
|
{ |
|
92
|
4 |
|
return $this->postcode; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @return string|null |
|
97
|
|
|
*/ |
|
98
|
2 |
|
public function getPostcodeEnd(): ?string |
|
99
|
|
|
{ |
|
100
|
2 |
|
return $this->postcodeEnd; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @return string|null |
|
105
|
|
|
*/ |
|
106
|
2 |
|
public function getCity(): ?string |
|
107
|
|
|
{ |
|
108
|
2 |
|
return $this->city; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @return string|null |
|
113
|
|
|
*/ |
|
114
|
2 |
|
public function getCountry(): ?string |
|
115
|
|
|
{ |
|
116
|
2 |
|
return $this->country; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @return bool |
|
121
|
|
|
*/ |
|
122
|
2 |
|
public function isMorningDelivery(): bool |
|
123
|
|
|
{ |
|
124
|
2 |
|
return $this->morningDelivery; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* New instance from data |
|
129
|
|
|
* |
|
130
|
|
|
* @param string $shipper |
|
131
|
|
|
* @param string|null $service |
|
132
|
|
|
* @param array<string,mixed> $data |
|
133
|
|
|
* |
|
134
|
|
|
* @return \Inspirum\Balikobot\Model\Values\PostCode |
|
135
|
|
|
*/ |
|
136
|
4 |
|
public static function newInstanceFromData(string $shipper, ?string $service, array $data): self |
|
137
|
|
|
{ |
|
138
|
4 |
|
return new self( |
|
139
|
4 |
|
$shipper, |
|
140
|
|
|
$service, |
|
141
|
4 |
|
$data['postcode'], |
|
142
|
4 |
|
$data['postcode_end'] ?? null, |
|
143
|
4 |
|
$data['city'] ?? null, |
|
144
|
4 |
|
$data['country'] ?? null, |
|
145
|
4 |
|
$data['1B'] ?? false |
|
146
|
|
|
); |
|
147
|
|
|
} |
|
148
|
|
|
} |
|
149
|
|
|
|