client = $this->createClient()->withAccessKey($access_key); } protected function createClient() { return new AviationStackClient(); } public function getFlights() { if (!$this->flights) { $this->flights = $this->client->get('/flights'); } return $this->flights; } public function getFlightByIata(string $iata) { $flights = $this->getFlights(); foreach ($flights->data as $flight) { if ($flight->flight->iata == $iata) { return $this->getNiceFlightData($flight); } } return false; } protected function getNiceFlightData($flight) { return '(' . $flight->flight_status . ')' . ' ' . $flight->departure->iata . '->' . $flight->arrival->iata . '. Dept: ' . $flight->departure->scheduled . '. Arr: ' . $flight->arrival->scheduled . '. ' . $flight->airline->name; } }