2019-08-23 02:32:49 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services\AirportLookup;
|
|
|
|
|
|
|
|
use App\Contracts\AirportLookup;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
2019-09-06 04:55:51 +08:00
|
|
|
use VaCentral\Contracts\IVaCentral;
|
|
|
|
use VaCentral\Exceptions\HttpException;
|
2019-08-23 02:32:49 +08:00
|
|
|
|
|
|
|
class VaCentralLookup extends AirportLookup
|
|
|
|
{
|
2019-09-06 04:55:51 +08:00
|
|
|
private $client;
|
|
|
|
|
|
|
|
public function __construct(IVaCentral $client)
|
|
|
|
{
|
|
|
|
$this->client = $client;
|
|
|
|
}
|
|
|
|
|
2019-08-23 02:32:49 +08:00
|
|
|
/**
|
|
|
|
* Lookup the information for an airport
|
|
|
|
*
|
|
|
|
* @param string $icao
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getAirport($icao)
|
|
|
|
{
|
|
|
|
try {
|
2019-09-06 04:55:51 +08:00
|
|
|
$airport = $this->client->getAirport($icao);
|
|
|
|
$airport->location = $airport->city;
|
|
|
|
return $airport;
|
2019-08-23 02:32:49 +08:00
|
|
|
} catch (HttpException $e) {
|
|
|
|
Log::error($e);
|
2019-09-06 04:55:51 +08:00
|
|
|
return [];
|
2019-08-23 02:32:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|