47be7507f0
* Account for empty ICAO; added tests * Fix null returns * Fix typo in volume units display * Add version field for bug report template * Some more changes to the bug report template
42 lines
777 B
PHP
42 lines
777 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Contracts\Metar as MetarProvider;
|
|
use App\Contracts\Service;
|
|
use App\Support\Metar;
|
|
|
|
/**
|
|
* Class AnalyticsService
|
|
*/
|
|
class AirportService extends Service
|
|
{
|
|
private $metarProvider;
|
|
|
|
public function __construct(
|
|
MetarProvider $metarProvider
|
|
) {
|
|
$this->metarProvider = $metarProvider;
|
|
}
|
|
|
|
/**
|
|
* Return the METAR for a given airport
|
|
*
|
|
* @param $icao
|
|
*
|
|
* @return Metar|null
|
|
*/
|
|
public function getMetar($icao)
|
|
{
|
|
$icao = trim($icao);
|
|
if ($icao === '') {
|
|
return;
|
|
}
|
|
|
|
$raw_metar = $this->metarProvider->get_metar($icao);
|
|
if ($raw_metar && $raw_metar !== '') {
|
|
return new Metar($raw_metar);
|
|
}
|
|
}
|
|
}
|