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
|
|
|
|
*
|
2020-06-04 22:36:55 +08:00
|
|
|
* @return mixed
|
2019-08-23 02:32:49 +08:00
|
|
|
*/
|
|
|
|
public function getAirport($icao)
|
|
|
|
{
|
|
|
|
try {
|
2019-09-06 04:55:51 +08:00
|
|
|
$airport = $this->client->getAirport($icao);
|
|
|
|
$airport->location = $airport->city;
|
2021-03-30 05:10:00 +08:00
|
|
|
$airport->timezone = $airport->tz;
|
2020-06-04 22:36:55 +08:00
|
|
|
|
2019-09-06 04:55:51 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|