Skip to content

Commit 18daa1d

Browse files
committed
drop support for laravel 10 and older dependencies, add return type hints
1 parent 74f201b commit 18daa1d

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
}
1919
],
2020
"require": {
21-
"illuminate/support": "^10.0|^11.0|^12.0"
21+
"illuminate/support": "^11.0|^12.0"
2222
},
2323
"require-dev": {
24-
"phpunit/phpunit": "^10.0|^11.0|^12.0",
25-
"mockery/mockery": "^1.4|^1.5|^1.6",
26-
"orchestra/testbench": "^7.0|^8.0|^9.0|^10.0"
24+
"phpunit/phpunit": "^11.0|^12.0",
25+
"mockery/mockery": "^1.5|^1.6",
26+
"orchestra/testbench": "^9.0|^10.0"
2727
},
2828
"autoload": {
2929
"psr-4": {

src/Country.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function toArray()
126126
'numericCode' => $this->getNumericCode(),
127127
'officialName' => $this->getOfficialName(),
128128
'commonName' => $this->getCommonName(),
129-
'currency' => $this->getCurrency(),
129+
'currency' => $this->getCurrency()->toArray(),
130130
];
131131
}
132132

@@ -211,7 +211,7 @@ public static function __callStatic($method, $parameters)
211211
*
212212
* @return array
213213
*/
214-
public function jsonSerialize()
214+
public function jsonSerialize(): mixed
215215
{
216216
return $this->toArray();
217217
}

src/Currency.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@ public function __construct(string $code, string $name, string $symbol)
1919
$this->symbol = $symbol;
2020
}
2121

22+
/**
23+
* Create a new instance of Currency
24+
*
25+
* @param array $data
26+
* @return void
27+
*/
28+
public static function make(array $data)
29+
{
30+
if (!isset($data['code'], $data['name'], $data['symbol'])) {
31+
throw new \InvalidArgumentException('The currency data is invalid.');
32+
}
33+
34+
return new static(
35+
$data['code'],
36+
$data['name'],
37+
$data['symbol']
38+
);
39+
}
40+
2241
/**
2342
* Get the currency's name.
2443
*
@@ -49,24 +68,6 @@ public function getSymbol()
4968
return $this->symbol;
5069
}
5170

52-
public function __toString()
53-
{
54-
return $this->name;
55-
}
56-
57-
public static function make(array $data)
58-
{
59-
if (!isset($data['code'], $data['name'], $data['symbol'])) {
60-
throw new \InvalidArgumentException('The currency data is invalid.');
61-
}
62-
63-
return new static(
64-
$data['code'],
65-
$data['name'],
66-
$data['symbol']
67-
);
68-
}
69-
7071
public function toArray()
7172
{
7273
return [
@@ -76,19 +77,18 @@ public function toArray()
7677
];
7778
}
7879

79-
/**
80-
* Get the instance as JSON.
81-
*
82-
* @param int $options
83-
* @return string
84-
*/
8580
public function toJson($options = 0)
8681
{
8782
return json_encode($this->toArray(), $options);
8883
}
8984

90-
public function jsonSerialize()
85+
public function jsonSerialize(): mixed
9186
{
9287
return $this->toArray();
9388
}
89+
90+
public function __toString()
91+
{
92+
return $this->name;
93+
}
9494
}

src/Facades/Countries.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @method static Array<\Orpheus\LaravelCountries\Country> getBySubregion(string $subregion)
2222
* @method static Array<\Orpheus\LaravelCountries\Country> getByCurrency(string $currency)
2323
* @method static Array<\Orpheus\LaravelCountries\Country> getAll(array $countries = [], bool $asCollection = false)
24-
* @method static \Orpheus\LaravelCountries\CountriesRepository getListForDropdown(string $key = 'alpha3Code', bool $official = false, string $localization = 'en')
24+
* @method static \Orpheus\LaravelCountries\CountriesRepository getListForDropdown(string $key = 'cca3', bool $official = false, string $localization = 'en')
2525
* @method static \Orpheus\LaravelCountries\CountriesRepository getRawData()
2626
*/
2727
class Countries extends Facade

0 commit comments

Comments
 (0)