|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Inspirum\Balikobot\Model\ZipCode; |
|
6
|
|
|
|
|
7
|
|
|
use Inspirum\Arrayable\BaseModel; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @extends \Inspirum\Arrayable\BaseModel<string,mixed> |
|
11
|
|
|
*/ |
|
12
|
|
|
final class DefaultZipCode extends BaseModel implements ZipCode |
|
13
|
|
|
{ |
|
14
|
8 |
|
public function __construct( |
|
15
|
|
|
private string $carrier, |
|
16
|
|
|
private ?string $service, |
|
17
|
|
|
private ?string $zipCode, |
|
18
|
|
|
private ?string $zipCodeEnd, |
|
19
|
|
|
private ?string $city, |
|
20
|
|
|
private ?string $region, |
|
21
|
|
|
private ?string $country, |
|
22
|
|
|
private bool $morningDelivery, |
|
23
|
|
|
) { |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
1 |
|
public function getCarrier(): string |
|
27
|
|
|
{ |
|
28
|
1 |
|
return $this->carrier; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
1 |
|
public function getService(): ?string |
|
32
|
|
|
{ |
|
33
|
1 |
|
return $this->service; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
1 |
|
public function getZipCode(): ?string |
|
37
|
|
|
{ |
|
38
|
1 |
|
return $this->zipCode; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
1 |
|
public function getZipCodeEnd(): ?string |
|
42
|
|
|
{ |
|
43
|
1 |
|
return $this->zipCodeEnd; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
1 |
|
public function getCity(): ?string |
|
47
|
|
|
{ |
|
48
|
1 |
|
return $this->city; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
1 |
|
public function getRegion(): ?string |
|
52
|
|
|
{ |
|
53
|
1 |
|
return $this->region; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
1 |
|
public function getCountry(): ?string |
|
57
|
|
|
{ |
|
58
|
1 |
|
return $this->country; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
1 |
|
public function isMorningDelivery(): bool |
|
62
|
|
|
{ |
|
63
|
1 |
|
return $this->morningDelivery; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** @inheritDoc */ |
|
67
|
1 |
|
public function __toArray(): array |
|
68
|
|
|
{ |
|
69
|
|
|
return [ |
|
|
|
|
|
|
70
|
1 |
|
'carrier' => $this->carrier, |
|
71
|
1 |
|
'service' => $this->service, |
|
72
|
1 |
|
'zipCode' => $this->zipCode, |
|
73
|
1 |
|
'zipCodeEnt' => $this->zipCodeEnd, |
|
74
|
1 |
|
'city' => $this->city, |
|
75
|
1 |
|
'region' => $this->region, |
|
76
|
1 |
|
'country' => $this->country, |
|
77
|
1 |
|
'morningDelivery' => $this->morningDelivery, |
|
78
|
|
|
]; |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: