From 8eb0a628733f1949ecc0f2c1686f8a59399cca8f Mon Sep 17 00:00:00 2001 From: Vladimir Romanichev Date: Mon, 13 Mar 2023 15:45:26 +0300 Subject: [PATCH] fix styles and bug --- src/Url/FromJson.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Url/FromJson.php b/src/Url/FromJson.php index 0595369..6f5d685 100644 --- a/src/Url/FromJson.php +++ b/src/Url/FromJson.php @@ -38,9 +38,11 @@ public function asString(): string public static function fromDomainAndBillingApi(Domain $domain, BillingApi $billingApi): self { $billingUrl = $billingApi->asString() . "/host/" . $domain->asString(); - new self( - file_get_contents($billingUrl) - ); + $jsonText = file_get_contents($billingUrl); + if ($jsonText === false) { + throw new \Exception('Can`t create FromJson object. Invalid server response.'); + } + return new self($jsonText); } private function validateResponse(\stdClass $json): void @@ -65,4 +67,4 @@ private function hostName(\stdClass $json): string { return $json->url; } -} \ No newline at end of file +}