Fix/metar reading (#353)
* Fix reading of the METAR information for AviationWeather. Fix the DI * StyleCI fixes
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
/**
|
||||
* Helper for HTTP stuff
|
||||
*/
|
||||
class Http
|
||||
{
|
||||
/**
|
||||
* Download a URI. If a file is given, it will save the downloaded
|
||||
* content into that file
|
||||
*
|
||||
* @param $uri
|
||||
* @param array $opts
|
||||
*
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get($uri, array $opts = [])
|
||||
{
|
||||
$opts = array_merge([
|
||||
'connect_timeout' => 2, // wait two seconds by default
|
||||
], $opts);
|
||||
|
||||
$client = new Client();
|
||||
$responseSeederService = $client->request('GET', $uri, $opts);
|
||||
|
||||
$body = $response->getBody()->getContents();
|
||||
if ($response->getHeader('content-type') === 'application/json') {
|
||||
$body = \GuzzleHttp\json_decode($body);
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Client as GuzzleClient;
|
||||
|
||||
/**
|
||||
* Helper for HTTP stuff
|
||||
@@ -12,7 +12,7 @@ class HttpClient
|
||||
private $httpClient;
|
||||
|
||||
public function __construct(
|
||||
Client $httpClient
|
||||
GuzzleClient $httpClient
|
||||
) {
|
||||
$this->httpClient = $httpClient;
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ class Metar implements \ArrayAccess
|
||||
/*
|
||||
* Other variables.
|
||||
*/
|
||||
private $raw;
|
||||
public $raw;
|
||||
|
||||
private $raw_parts = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user