Fix/metar reading (#353)

* Fix reading of the METAR information for AviationWeather. Fix the DI

* StyleCI fixes
This commit is contained in:
Nabeel S
2019-08-08 14:52:34 -04:00
committed by GitHub
parent becf6c95f0
commit 5cafebe4d6
11 changed files with 121 additions and 100 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -310,7 +310,7 @@ class Metar implements \ArrayAccess
/*
* Other variables.
*/
private $raw;
public $raw;
private $raw_parts = [];