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