Skip to content

Commit

Permalink
Further testing and fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Muffinman committed Jan 18, 2023
1 parent 82719ec commit 9c7c882
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Concerns/ApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function createAccessToken(string $baseUrl, string $email, string
]
]);

$token = json_decode($response->getBody()->getContents());
$token = json_decode($response->getBody()->getContents(), true);
} catch (\Exception $e) {
throw new \Exception('Unable to get access token: ' . $e->getMessage());
}
Expand Down Expand Up @@ -74,6 +74,6 @@ protected function request(string $type, string $endpoint, ?array $query = null,
'json' => $data,
]);

return json_decode($response->getBody()->getContents());
return json_decode($response->getBody()->getContents(), true);
}
}
8 changes: 5 additions & 3 deletions src/Models/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ abstract class BaseModel {

public static function fromArray(array $data): static
{
$host = new static;
$model = new static;

foreach ($data as $k => $v) {
if (property_exists($host, $k)) {
$host->{$k} = $v;
if (property_exists($model, $k)) {
$model->{$k} = $v;
}
}

return $model;
}
}
2 changes: 1 addition & 1 deletion src/Models/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Host extends BaseModel implements Model

public bool $http2_support = true;

public array $locations = [];
public ?array $locations = [];

public array $meta = [
'dns_challenge' => true,
Expand Down

0 comments on commit 9c7c882

Please sign in to comment.