mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 15:02:34 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -47,7 +47,7 @@ public function data(array $input): array
|
||||
/**
|
||||
* @throws CouldNotConnectToProvider
|
||||
*/
|
||||
public function connect(?array $credentials = null): bool
|
||||
public function connect(array $credentials): bool
|
||||
{
|
||||
try {
|
||||
$connect = Http::withToken($credentials['token'])->get($this->apiUrl.'/account');
|
||||
@ -65,21 +65,23 @@ public function connect(?array $credentials = null): bool
|
||||
public function plans(?string $region): array
|
||||
{
|
||||
try {
|
||||
/** @var array<string, mixed> $plans */
|
||||
$plans = Http::withToken($this->serverProvider->credentials['token'])
|
||||
->get($this->apiUrl.'/linode/types')
|
||||
->json();
|
||||
|
||||
return collect($plans['data'])
|
||||
->mapWithKeys(function ($value) {
|
||||
return [
|
||||
$value['id'] => __('server_providers.plan', [
|
||||
'name' => $value['label'],
|
||||
'cpu' => $value['vcpus'],
|
||||
'memory' => $value['memory'],
|
||||
'disk' => $value['disk'],
|
||||
]),
|
||||
];
|
||||
})
|
||||
/** @var array<int, array<string, mixed>> $plansData */
|
||||
$plansData = $plans['data'];
|
||||
|
||||
return collect($plansData)
|
||||
->mapWithKeys(fn (array $value) => [
|
||||
$value['id'] => __('server_providers.plan', [
|
||||
'name' => $value['label'],
|
||||
'cpu' => $value['vcpus'],
|
||||
'memory' => $value['memory'],
|
||||
'disk' => $value['disk'],
|
||||
]),
|
||||
])
|
||||
->toArray();
|
||||
} catch (Exception) {
|
||||
return [];
|
||||
@ -89,12 +91,16 @@ public function plans(?string $region): array
|
||||
public function regions(): array
|
||||
{
|
||||
try {
|
||||
/** @var array<string, mixed> $regions */
|
||||
$regions = Http::withToken($this->serverProvider->credentials['token'])
|
||||
->get($this->apiUrl.'/regions')
|
||||
->json();
|
||||
|
||||
return collect($regions['data'])
|
||||
->mapWithKeys(fn ($value) => [$value['id'] => $value['label']])
|
||||
/** @var array<int, array<string, mixed>> $regionsData */
|
||||
$regionsData = $regions['data'];
|
||||
|
||||
return collect($regionsData)
|
||||
->mapWithKeys(fn (array $value) => [$value['id'] => $value['label']])
|
||||
->toArray();
|
||||
} catch (Exception) {
|
||||
return [];
|
||||
|
Reference in New Issue
Block a user