From 6824dd8cbc1ff5c3a4072be4a0536b6d003bf1d4 Mon Sep 17 00:00:00 2001 From: Fbenas Date: Wed, 4 Nov 2020 18:25:16 +0000 Subject: Inital Commit --- src/App.php | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/App.php (limited to 'src/App.php') diff --git a/src/App.php b/src/App.php new file mode 100644 index 0000000..bb92b87 --- /dev/null +++ b/src/App.php @@ -0,0 +1,58 @@ +config) { + $config = include __DIR__ . '/../config.php'; + $this->config = $config; + } + + if (!$value) { + return $config; + } + + if (!array_key_exists($value, $config)) { + throw new Exception('Failed loading config value `' . $value . '`'); + } + + return $config[$value]; + } + + public function initCommands() + { + $api_key = $this->getConfig('api_key'); + + $this->addCommand( + 'flight:check {flight}', + function (InputInterface $input, OutputInterface $output) use ($api_key) { + $flight_data = (new Helper($api_key))->getFlightByIata($input->getArgument('flight')); + $output->writeLn($flight_data); + return Command::SUCCESS; + } + ); + + $this->addCommand( + 'flight {flight}', + function (InputInterface $input, OutputInterface $output) use ($api_key) { + $flight_data = (new Helper($api_key))->getFlightByIata($input->getArgument('flight')); + $output->writeLn($flight_data); + return Command::SUCCESS; + } + ); + } +} -- cgit v1.2.3