diff --git a/lib/Helpers/MetarHTTPClient.php b/lib/Helpers/MetarHTTPClient.php index 0624401..956df6a 100644 --- a/lib/Helpers/MetarHTTPClient.php +++ b/lib/Helpers/MetarHTTPClient.php @@ -1,8 +1,10 @@ guzzleConf = $config; } @@ -37,9 +39,9 @@ public function __construct($config = []) /** * Make a HTTP request and retrieve the body. * @param string $url The URL to request - * @return \Psr\Http\Message\StreamInterface + * @throws \GuzzleHttp\Exception\GuzzleException */ - public function getMetarAPIResponse($url) + public function getMetarAPIResponse(string $url): string { $client = new HttpClient($this->guzzleConf); $response = $client->get($url); diff --git a/lib/Metar.php b/lib/Metar.php index e96d221..e036e18 100644 --- a/lib/Metar.php +++ b/lib/Metar.php @@ -1,4 +1,7 @@ icao = $icao; } - private function getMetarDataString() + /** @throws \GuzzleHttp\Exception\GuzzleException */ + private function getMetarDataString(): string { - - $data = $this->getMetarAPIResponse(str_replace('{{_ICAO_}}', $this->icao, $this->serviceUrl)); - return $data; + return $this->getMetarAPIResponse(str_replace('{{_ICAO_}}', $this->icao, $this->serviceUrl)); } - public function __toString() + public function __toString(): string { return $this->getMetarDataString(); } diff --git a/lib/Providers/MetarProviderInterface.php b/lib/Providers/MetarProviderInterface.php index ce221e2..03971d9 100644 --- a/lib/Providers/MetarProviderInterface.php +++ b/lib/Providers/MetarProviderInterface.php @@ -1,4 +1,7 @@ icao = $icao; } - private function getMetarDataString() + /** @throws \GuzzleHttp\Exception\GuzzleException */ + private function getMetarDataString(): string { $data = $this->getMetarAPIResponse(str_replace('{{_ICAO_}}', $this->icao, $this->serviceUrl)); diff --git a/lib/Providers/Vatsim.php b/lib/Providers/Vatsim.php index 1ab2778..c229d84 100644 --- a/lib/Providers/Vatsim.php +++ b/lib/Providers/Vatsim.php @@ -1,4 +1,7 @@ icao = $icao; } - private function getMetarDataString() + /** @throws \GuzzleHttp\Exception\GuzzleException */ + private function getMetarDataString(): string { $data = $this->getMetarAPIResponse(str_replace('{{_ICAO_}}', $this->icao, $this->serviceUrl)); return trim($data); diff --git a/tests/MetarHttpClientTest.php b/tests/MetarHttpClientTest.php index 3e43a51..49cbe82 100644 --- a/tests/MetarHttpClientTest.php +++ b/tests/MetarHttpClientTest.php @@ -1,5 +1,8 @@