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
|
7 |
|
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 $country, |
21
|
|
|
private bool $morningDelivery |
22
|
|
|
) { |
23
|
|
|
} |
24
|
|
|
|
25
|
1 |
|
public function getCarrier(): string |
26
|
|
|
{ |
27
|
1 |
|
return $this->carrier; |
28
|
|
|
} |
29
|
|
|
|
30
|
1 |
|
public function getService(): ?string |
31
|
|
|
{ |
32
|
1 |
|
return $this->service; |
33
|
|
|
} |
34
|
|
|
|
35
|
1 |
|
public function getZipCode(): ?string |
36
|
|
|
{ |
37
|
1 |
|
return $this->zipCode; |
38
|
|
|
} |
39
|
|
|
|
40
|
1 |
|
public function getZipCodeEnd(): ?string |
41
|
|
|
{ |
42
|
1 |
|
return $this->zipCodeEnd; |
43
|
|
|
} |
44
|
|
|
|
45
|
1 |
|
public function getCity(): ?string |
46
|
|
|
{ |
47
|
1 |
|
return $this->city; |
48
|
|
|
} |
49
|
|
|
|
50
|
1 |
|
public function getCountry(): ?string |
51
|
|
|
{ |
52
|
1 |
|
return $this->country; |
53
|
|
|
} |
54
|
|
|
|
55
|
1 |
|
public function isMorningDelivery(): bool |
56
|
|
|
{ |
57
|
1 |
|
return $this->morningDelivery; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** @inheritDoc */ |
61
|
1 |
|
public function __toArray(): array |
62
|
|
|
{ |
63
|
|
|
return [ |
|
|
|
|
64
|
1 |
|
'carrier' => $this->carrier, |
65
|
1 |
|
'service' => $this->service, |
66
|
1 |
|
'zipCode' => $this->zipCode, |
67
|
1 |
|
'zipCodeEnt' => $this->zipCodeEnd, |
68
|
1 |
|
'city' => $this->city, |
69
|
1 |
|
'country' => $this->country, |
70
|
1 |
|
'morningDelivery' => $this->morningDelivery, |
71
|
|
|
]; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: