|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Inspirum\Balikobot\Model\Package; |
|
6
|
|
|
|
|
7
|
|
|
use Inspirum\Arrayable\BaseModel; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @extends \Inspirum\Arrayable\BaseModel<string,mixed> |
|
11
|
|
|
*/ |
|
12
|
|
|
final class DefaultPackage extends BaseModel implements Package |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @param array<string> $pieces |
|
16
|
|
|
*/ |
|
17
|
26 |
|
public function __construct( |
|
18
|
|
|
private readonly string $carrier, |
|
19
|
|
|
private readonly string $packageId, |
|
20
|
|
|
private readonly string $batchId, |
|
21
|
|
|
private readonly string $carrierId, |
|
22
|
|
|
private readonly ?string $trackUrl = null, |
|
23
|
|
|
private readonly ?string $labelUrl = null, |
|
24
|
|
|
private readonly ?string $carrierIdSwap = null, |
|
25
|
|
|
private readonly array $pieces = [], |
|
26
|
|
|
private readonly ?string $finalCarrierId = null, |
|
27
|
|
|
private readonly ?string $finalTrackUrl = null, |
|
28
|
|
|
private readonly ?string $barcode = null, |
|
29
|
|
|
) { |
|
30
|
26 |
|
} |
|
31
|
|
|
|
|
32
|
13 |
|
public function getPackageId(): string |
|
33
|
|
|
{ |
|
34
|
13 |
|
return $this->packageId; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
2 |
|
public function getBatchId(): string |
|
38
|
|
|
{ |
|
39
|
2 |
|
return $this->batchId; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
public function getTrackUrl(): ?string |
|
43
|
|
|
{ |
|
44
|
1 |
|
return $this->trackUrl; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
1 |
|
public function getLabelUrl(): ?string |
|
48
|
|
|
{ |
|
49
|
1 |
|
return $this->labelUrl; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
1 |
|
public function getCarrierIdSwap(): ?string |
|
53
|
|
|
{ |
|
54
|
1 |
|
return $this->carrierIdSwap; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return array<string> |
|
59
|
|
|
*/ |
|
60
|
1 |
|
public function getPieces(): array |
|
61
|
|
|
{ |
|
62
|
1 |
|
return $this->pieces; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
1 |
|
public function getFinalCarrierId(): ?string |
|
66
|
|
|
{ |
|
67
|
1 |
|
return $this->finalCarrierId; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
1 |
|
public function getFinalTrackUrl(): ?string |
|
71
|
|
|
{ |
|
72
|
1 |
|
return $this->finalTrackUrl; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function getBarcode(): ?string |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->barcode; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
26 |
|
public function getCarrier(): string |
|
81
|
|
|
{ |
|
82
|
26 |
|
return $this->carrier; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
11 |
|
public function getCarrierId(): string |
|
86
|
|
|
{ |
|
87
|
11 |
|
return $this->carrierId; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** @inheritDoc */ |
|
91
|
3 |
|
public function __toArray(): array |
|
92
|
|
|
{ |
|
93
|
3 |
|
return [ |
|
|
|
|
|
|
94
|
3 |
|
'carrier' => $this->carrier, |
|
95
|
3 |
|
'carrierId' => $this->carrierId, |
|
96
|
3 |
|
'packageId' => $this->packageId, |
|
97
|
3 |
|
'batchId' => $this->batchId, |
|
98
|
3 |
|
'trackUrl' => $this->trackUrl, |
|
99
|
3 |
|
'labelUrl' => $this->labelUrl, |
|
100
|
3 |
|
'carrierIdSwap' => $this->carrierIdSwap, |
|
101
|
3 |
|
'pieces' => $this->pieces, |
|
102
|
3 |
|
'finalCarrierId' => $this->finalCarrierId, |
|
103
|
3 |
|
'finalTrackUrl' => $this->finalTrackUrl, |
|
104
|
3 |
|
'barcode' => $this->barcode, |
|
105
|
3 |
|
]; |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: