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

@@ -3,7 +3,7 @@
namespace App\Widgets;
use App\Contracts\Widget;
use App\Support\Metar;
use App\Services\AirportService;
/**
* This is a widget for the 3rd party CheckWX service
@@ -14,26 +14,13 @@ class Weather extends Widget
'icao' => null,
];
public const URL = 'https://avwx.rest/api/metar/';
/**
* Attempt to get the data from the CheckWX API
*/
public function run()
{
/**
* @var \App\Contracts\Metar
*/
$klass = config('phpvms.metar');
$metar_class = new $klass();
$metar = null;
$wind = null;
$raw_metar = $metar_class->get_metar($this->config['icao']);
if ($raw_metar && $raw_metar !== '') {
$metar = new Metar($raw_metar);
}
$airportSvc = app(AirportService::class);
$metar = $airportSvc->getMetar($this->config['icao']);
return view('widgets.weather', [
'config' => $this->config,