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