diff --git a/app/Awards/PilotFlightAwards.php b/app/Awards/PilotFlightAwards.php index 43190cc5..4955550d 100644 --- a/app/Awards/PilotFlightAwards.php +++ b/app/Awards/PilotFlightAwards.php @@ -7,13 +7,13 @@ use App\Interfaces\Award; /** * Simple example of an awards class, where you can apply an award when a user * has 100 flights. All award classes need to extend the AwardInterface - * @package App\Awards */ class PilotFlightAwards extends Award { /** * Set the name of this award class to make it easier to see when * assigning to a specific award + * * @var string */ public $name = 'Pilot Flights'; @@ -22,6 +22,7 @@ class PilotFlightAwards extends Award * The description to show under the parameters field, so the admin knows * what the parameter actually controls. You can leave this blank if there * isn't a parameter. + * * @var string */ public $param_description = 'The number of flights at which to give this award'; @@ -33,7 +34,9 @@ class PilotFlightAwards extends Award * If no parameter is passed in, just default it to 100. You should check if there * is a parameter or not. You can call it whatever you want, since that would make * sense with the $param_description. + * * @param int|null $number_of_flights The parameters passed in from the UI + * * @return bool */ public function check($number_of_flights = null): bool diff --git a/app/Bootstrap/LoadConfiguration.php b/app/Bootstrap/LoadConfiguration.php index bd1d2cc9..76782c77 100644 --- a/app/Bootstrap/LoadConfiguration.php +++ b/app/Bootstrap/LoadConfiguration.php @@ -7,30 +7,22 @@ use Illuminate\Contracts\Foundation\Application; /** * Class LoadConfiguration - * @package App\Bootstrap - * - * I'm overriding this to take advantage of the configuration caching - * and not needing to read the files from disk every time. - * - * Hopefully it won't affect anything within core framework but this - * should be ok. Will just have to be cognizant of any changes to the - * LoadConfiguration parent class, or if the Kernel changes the boot - * order -NS */ class LoadConfiguration extends \Illuminate\Foundation\Bootstrap\LoadConfiguration { /** * Load the configuration items from all of the files. * - * @param \Illuminate\Contracts\Foundation\Application $app - * @param \Illuminate\Contracts\Config\Repository $repository + * @param \Illuminate\Contracts\Foundation\Application $app + * @param \Illuminate\Contracts\Config\Repository $repository + * * @throws \Exception */ protected function loadConfigurationFiles(Application $app, RepositoryContract $repository) { parent::loadConfigurationFiles($app, $repository); - /** + /* * Read in the base config, only if it exists */ if (file_exists($app->basePath().'/config.php')) { diff --git a/app/Console/Command.php b/app/Console/Command.php index 6be4a2f6..b073440d 100644 --- a/app/Console/Command.php +++ b/app/Console/Command.php @@ -7,7 +7,6 @@ use Symfony\Component\Process\Process; /** * Class BaseCommand - * @package App\Console */ abstract class Command extends \Illuminate\Console\Command { @@ -52,7 +51,9 @@ abstract class Command extends \Illuminate\Console\Command /** * Streaming file reader + * * @param $filename + * * @return \Generator */ public function readFile($filename): ?\Generator @@ -71,16 +72,19 @@ abstract class Command extends \Illuminate\Console\Command } /** - * @param $cmd - * @param bool $return - * @return string + * @param $cmd + * @param bool $return + * @param mixed $verbose + * * @throws \Symfony\Component\Process\Exception\RuntimeException * @throws \Symfony\Component\Process\Exception\LogicException + * + * @return string */ public function runCommand($cmd, $return = false, $verbose = true): string { if (\is_array($cmd)) { - $cmd = join(' ', $cmd); + $cmd = implode(' ', $cmd); } if ($verbose) { diff --git a/app/Console/Commands/AcarsReplay.php b/app/Console/Commands/AcarsReplay.php index 69e83d29..f52671d2 100644 --- a/app/Console/Commands/AcarsReplay.php +++ b/app/Console/Commands/AcarsReplay.php @@ -9,7 +9,6 @@ use Illuminate\Database\Eloquent\Collection; /** * Class AcarsReplay - * @package App\Console\Commands */ class AcarsReplay extends Command { @@ -18,12 +17,14 @@ class AcarsReplay extends Command /** * API Key to post as + * * @var string */ protected $apiKey = 'testadminapikey'; /** * For automatic updates, how many seconds to sleep between updates + * * @var int */ protected $sleepTime = 10; @@ -50,19 +51,22 @@ class AcarsReplay extends Command 'base_uri' => config('app.url'), 'headers' => [ 'Authorization' => $this->apiKey, - ] + ], ]); } /** * Make a request to start a PIREP + * * @param \stdClass $flight - * @return string + * * @throws \RuntimeException + * + * @return string */ protected function startPirep($flight): string { - # convert the planned flight time to be completely in minutes + // convert the planned flight time to be completely in minutes $pft = Utils::hoursToMinutes( $flight->planned_hrsenroute, $flight->planned_minenroute @@ -80,7 +84,7 @@ class AcarsReplay extends Command 'level' => $flight->planned_altitude, 'planned_flight_time' => $pft, 'route' => $flight->planned_route, - ] + ], ]); $body = \json_decode($response->getBody()->getContents()); @@ -90,14 +94,17 @@ class AcarsReplay extends Command /** * Mark the PIREP as filed + * * @param $pirep_id - * @return mixed + * * @throws \RuntimeException + * + * @return mixed */ protected function filePirep($pirep_id) { $response = $this->httpClient->post('/api/pireps/'.$pirep_id.'/file', [ - 'json' => [] + 'json' => [], ]); $body = \json_decode($response->getBody()->getContents()); @@ -108,8 +115,10 @@ class AcarsReplay extends Command /** * @param $pirep_id * @param $data - * @return array + * * @throws \RuntimeException + * + * @return array */ protected function postUpdate($pirep_id, $data) { @@ -127,15 +136,15 @@ class AcarsReplay extends Command $upd = [ 'positions' => [ - $position - ] + $position, + ], ]; $this->info("Update: $data->callsign, $position[lat] x $position[lon] \t\t" ."hdg: $position[heading]\t\talt: $position[altitude]\t\tgs: $position[gs]"); $response = $this->httpClient->post($uri, [ - 'json' => $upd + 'json' => $upd, ]); $body = \json_decode($response->getBody()->getContents()); @@ -146,13 +155,15 @@ class AcarsReplay extends Command $position['lon'], $position['heading'], $position['altitude'], - $position['gs'] + $position['gs'], ]; } /** * Parse this file and run the updates + * * @param array $files + * * @throws \RuntimeException */ protected function updatesFromFile(array $files) @@ -168,20 +179,19 @@ class AcarsReplay extends Command $contents = \json_decode($contents); return collect($contents->updates); - } else { - $this->error($file.' not found, skipping'); - - return false; } + $this->error($file.' not found, skipping'); + + return false; }) - # remove any of errored file entries + // remove any of errored file entries ->filter(function ($value, $key) { return $value !== false; }); $this->info('Starting playback'); - /** + /* * File the initial pirep to get a "preflight" status */ $flights->each(function ($updates, $idx) { @@ -191,7 +201,7 @@ class AcarsReplay extends Command $this->info('Prefiled '.$update->callsign.', ID: '.$pirep_id); }); - /** + /* * Iterate through all of the flights, retrieving the updates * from each individual flight. Remove the update. Continue through * until there are no updates left, at which point we remove the flight @@ -206,7 +216,7 @@ class AcarsReplay extends Command $this->postUpdate($pirep_id, $update); - # we're done and don't put the "no-submit" option + // we're done and don't put the "no-submit" option if ($updates->count() === 0 && !$this->option('no-submit')) { $this->filePirep($pirep_id); } @@ -226,8 +236,10 @@ class AcarsReplay extends Command /** * Execute the console command. - * @return mixed + * * @throws \RuntimeException + * + * @return mixed */ public function handle() { diff --git a/app/Console/Commands/ComposerCommand.php b/app/Console/Commands/ComposerCommand.php index f828dbc8..086cb311 100644 --- a/app/Console/Commands/ComposerCommand.php +++ b/app/Console/Commands/ComposerCommand.php @@ -7,7 +7,6 @@ use Artisan; /** * Class ComposerCommand - * @package App\Console\Commands */ class ComposerCommand extends Command { @@ -19,8 +18,7 @@ class ComposerCommand extends Command */ public function handle() { - switch(trim($this->argument('cmd'))) - { + switch (trim($this->argument('cmd'))) { case 'post-update': $this->postUpdate(); break; diff --git a/app/Console/Commands/CreateDatabase.php b/app/Console/Commands/CreateDatabase.php index e4e626e8..ea821cbb 100644 --- a/app/Console/Commands/CreateDatabase.php +++ b/app/Console/Commands/CreateDatabase.php @@ -7,7 +7,6 @@ use Log; /** * Class CreateDatabase - * @package App\Console\Commands */ class CreateDatabase extends Command { @@ -26,7 +25,9 @@ class CreateDatabase extends Command /** * Create the mysql database + * * @param $dbkey + * * @return bool */ protected function create_mysql($dbkey) @@ -52,6 +53,7 @@ class CreateDatabase extends Command if ($this->option('reset') === true) { $sql = "DROP DATABASE IF EXISTS `$name`"; + try { Log::info('Dropping database: '.$sql); $conn->exec($sql); @@ -74,6 +76,7 @@ class CreateDatabase extends Command /** * Create the sqlite database + * * @param $dbkey */ protected function create_sqlite($dbkey) diff --git a/app/Console/Commands/DevCommands.php b/app/Console/Commands/DevCommands.php index 2e42cd3f..adeb437f 100644 --- a/app/Console/Commands/DevCommands.php +++ b/app/Console/Commands/DevCommands.php @@ -15,7 +15,6 @@ use Symfony\Component\Yaml\Yaml; /** * Class DevCommands - * @package App\Console\Commands */ class DevCommands extends Command { @@ -25,6 +24,7 @@ class DevCommands extends Command /** * DevCommands constructor. + * * @param DatabaseService $dbSvc */ public function __construct(DatabaseService $dbSvc) @@ -173,7 +173,7 @@ class DevCommands extends Command } $yaml[$table_name][] = $yaml_row; - ++$count; + $count++; } $this->info('Exporting '.$count.' rows'); @@ -198,9 +198,8 @@ class DevCommands extends Command $yml = Yaml::parse(file_get_contents($file)); foreach ($yml as $table => $rows) { - - $this->info('Importing table ' . $table); - $this->info('Number of rows: ' . \count($rows)); + $this->info('Importing table '.$table); + $this->info('Number of rows: '.\count($rows)); foreach ($rows as $row) { try { diff --git a/app/Console/Commands/DevInstall.php b/app/Console/Commands/DevInstall.php index 10fb9aef..652aef19 100644 --- a/app/Console/Commands/DevInstall.php +++ b/app/Console/Commands/DevInstall.php @@ -7,7 +7,6 @@ use Modules\Installer\Services\ConfigService; /** * Create a fresh development install - * @package App\Console\Commands */ class DevInstall extends Command { @@ -24,6 +23,7 @@ class DevInstall extends Command /** * Run dev related commands + * * @throws \Symfony\Component\HttpFoundation\File\Exception\FileException */ public function handle() @@ -32,7 +32,7 @@ class DevInstall extends Command $this->rewriteConfigs(); } - # Reload the configuration + // Reload the configuration \App::boot(); $this->info('Recreating database'); @@ -45,13 +45,13 @@ class DevInstall extends Command '--seed' => true, ]); - # - # + // + // $this->info('Importing sample data'); - foreach($this->yaml_imports as $yml) { + foreach ($this->yaml_imports as $yml) { $this->call('phpvms:yaml-import', [ - 'files' => ['app/Database/seeds/' . $yml], + 'files' => ['app/Database/seeds/'.$yml], ]); } @@ -60,6 +60,7 @@ class DevInstall extends Command /** * Rewrite the configuration files + * * @throws \Symfony\Component\HttpFoundation\File\Exception\FileException */ protected function rewriteConfigs() @@ -68,7 +69,7 @@ class DevInstall extends Command $this->info('Removing the old config files'); - # Remove the old files + // Remove the old files $config_file = base_path('config.php'); if (file_exists($config_file)) { unlink($config_file); diff --git a/app/Console/Commands/ImportCsv.php b/app/Console/Commands/ImportCsv.php index dceb3374..4621a2aa 100644 --- a/app/Console/Commands/ImportCsv.php +++ b/app/Console/Commands/ImportCsv.php @@ -1,7 +1,4 @@ importer->importSubfleets($file); } - foreach($status['success'] as $line) { + foreach ($status['success'] as $line) { $this->info($line); } diff --git a/app/Console/Commands/ImportFromClassic.php b/app/Console/Commands/ImportFromClassic.php index a5380f99..35183f78 100644 --- a/app/Console/Commands/ImportFromClassic.php +++ b/app/Console/Commands/ImportFromClassic.php @@ -19,7 +19,7 @@ class ImportFromClassic extends Command 'name' => $this->argument('db_name'), 'user' => $this->argument('db_user'), 'pass' => $this->argument('db_pass'), - 'table_prefix' => $this->argument('table_prefix') + 'table_prefix' => $this->argument('table_prefix'), ]; $importerSvc = new \App\Console\Services\Importer($db_creds); diff --git a/app/Console/Commands/NavdataImport.php b/app/Console/Commands/NavdataImport.php index b993e404..93550d76 100644 --- a/app/Console/Commands/NavdataImport.php +++ b/app/Console/Commands/NavdataImport.php @@ -8,7 +8,6 @@ use App\Models\Navdata; /** * Class NavdataImport - * @package App\Console\Commands */ class NavdataImport extends Command { @@ -16,8 +15,9 @@ class NavdataImport extends Command protected $description = ''; /** - * @return void * @throws \League\Geotools\Exception\InvalidArgumentException + * + * @return void */ public function handle() { @@ -31,8 +31,10 @@ class NavdataImport extends Command /** * Read and parse in the navaid file - * @return void + * * @throws \League\Geotools\Exception\InvalidArgumentException + * + * @return void */ public function read_wp_nav_aid(): void { @@ -87,7 +89,7 @@ class NavdataImport extends Command 'class' => trim($line[60]), ]; - # Map to the Navaid enum + // Map to the Navaid enum switch ($navaid['type']) { case 'ILS': $navaid['type'] = NavaidType::LOC; @@ -117,7 +119,7 @@ class NavdataImport extends Command }*/ Navdata::updateOrCreate([ - 'id' => $navaid['id'], 'name' => $navaid['name'] + 'id' => $navaid['id'], 'name' => $navaid['name'], ], $navaid); $imported++; @@ -173,7 +175,7 @@ class NavdataImport extends Command ]; Navdata::updateOrCreate([ - 'id' => $navfix['id'], 'name' => $navfix['name'] + 'id' => $navfix['id'], 'name' => $navfix['name'], ], $navfix); $imported++; diff --git a/app/Console/Commands/TestApi.php b/app/Console/Commands/TestApi.php index a4d01723..d65441cf 100644 --- a/app/Console/Commands/TestApi.php +++ b/app/Console/Commands/TestApi.php @@ -7,7 +7,6 @@ use GuzzleHttp\Client; /** * Class TestApi - * @package App\Console\Commands */ class TestApi extends Command { @@ -24,7 +23,7 @@ class TestApi extends Command 'Authorization' => $this->argument('apikey'), 'Content-type' => 'application/json', 'X-API-Key' => $this->argument('apikey'), - ] + ], ]); $result = $this->httpClient->get($this->argument('url')); diff --git a/app/Console/Commands/Version.php b/app/Console/Commands/Version.php index 5e2bd52f..cd153de6 100644 --- a/app/Console/Commands/Version.php +++ b/app/Console/Commands/Version.php @@ -7,7 +7,6 @@ use Symfony\Component\Yaml\Yaml; /** * Class Version - * @package App\Console\Commands */ class Version extends Command { @@ -15,13 +14,15 @@ class Version extends Command /** * Create the version number that gets written out + * + * @param mixed $cfg */ protected function createVersionNumber($cfg) { exec($cfg['git']['git-local'], $version); $version = substr($version[0], 0, $cfg['build']['length']); - # prefix with the date in YYMMDD format + // prefix with the date in YYMMDD format $date = date('ymd'); $version = $date.'-'.$version; @@ -30,6 +31,7 @@ class Version extends Command /** * Run dev related commands + * * @throws \Symfony\Component\Yaml\Exception\ParseException */ public function handle() @@ -37,7 +39,7 @@ class Version extends Command $version_file = config_path('version.yml'); $cfg = Yaml::parse(file_get_contents($version_file)); - # Get the current build id + // Get the current build id $build_number = $this->createVersionNumber($cfg); $cfg['build']['number'] = $build_number; @@ -48,13 +50,13 @@ class Version extends Command file_put_contents($version_file, Yaml::dump($cfg, 4, 2)); } - # Only show the major.minor.patch version + // Only show the major.minor.patch version if ($this->option('base-only')) { $version = 'v'.$cfg['current']['major'].'.' .$cfg['current']['minor'].'.' .$cfg['current']['patch']; } - print $version."\n"; + echo $version."\n"; } } diff --git a/app/Console/Commands/YamlExport.php b/app/Console/Commands/YamlExport.php index f5c5902a..19775c92 100644 --- a/app/Console/Commands/YamlExport.php +++ b/app/Console/Commands/YamlExport.php @@ -9,7 +9,6 @@ use Symfony\Component\Yaml\Yaml; /** * Class YamlExport - * @package App\Console\Commands */ class YamlExport extends Command { @@ -18,6 +17,7 @@ class YamlExport extends Command /** * YamlExport constructor. + * * @param DatabaseService $dbSvc */ public function __construct(DatabaseService $dbSvc) @@ -47,6 +47,6 @@ class YamlExport extends Command } $yaml = Yaml::dump($export_tables, 4, 2); - print($yaml); + echo $yaml; } } diff --git a/app/Console/Commands/YamlImport.php b/app/Console/Commands/YamlImport.php index d7725dc0..8eb137a9 100644 --- a/app/Console/Commands/YamlImport.php +++ b/app/Console/Commands/YamlImport.php @@ -7,7 +7,6 @@ use App\Services\DatabaseService; /** * Class YamlImport - * @package App\Console\Commands */ class YamlImport extends Command { @@ -17,6 +16,7 @@ class YamlImport extends Command /** * YamlImport constructor. + * * @param DatabaseService $dbSvc */ public function __construct(DatabaseService $dbSvc) @@ -27,6 +27,7 @@ class YamlImport extends Command /** * Run dev related commands + * * @throws \Exception */ public function handle() diff --git a/app/Console/Cron/Hourly.php b/app/Console/Cron/Hourly.php index def6d7c5..e278b7fd 100644 --- a/app/Console/Cron/Hourly.php +++ b/app/Console/Cron/Hourly.php @@ -8,7 +8,6 @@ use App\Events\CronHourly; /** * This just calls the CronHourly event, so all of the * listeners, etc can just be called to run those tasks - * @package App\Console\Cron */ class Hourly extends Command { @@ -16,9 +15,6 @@ class Hourly extends Command protected $description = 'Run the hourly cron tasks'; protected $schedule; - /** - * - */ public function handle(): void { $this->redirectLoggingToStdout('cron'); diff --git a/app/Console/Cron/Monthly.php b/app/Console/Cron/Monthly.php index f18fcfcd..efa3e445 100644 --- a/app/Console/Cron/Monthly.php +++ b/app/Console/Cron/Monthly.php @@ -10,9 +10,6 @@ use App\Events\CronMonthly; * listeners, etc can just be called to run those tasks * * The actual cron tasks are in app/Cron - * - * @package App\Console\Cron - * */ class Monthly extends Command { @@ -20,9 +17,6 @@ class Monthly extends Command protected $description = 'Run the monthly cron tasks'; protected $schedule; - /** - * - */ public function handle(): void { $this->redirectLoggingToStdout('cron'); diff --git a/app/Console/Cron/Nightly.php b/app/Console/Cron/Nightly.php index 1b2d69ad..9f0131dd 100644 --- a/app/Console/Cron/Nightly.php +++ b/app/Console/Cron/Nightly.php @@ -8,10 +8,8 @@ use App\Events\CronNightly; /** * This just calls the CronNightly event, so all of the * listeners, etc can just be called to run those tasks - * - * The actual cron tasks are in app/Cron * - * @package App\Console\Cron + * The actual cron tasks are in app/Cron */ class Nightly extends Command { @@ -19,9 +17,6 @@ class Nightly extends Command protected $description = 'Run the nightly cron tasks'; protected $schedule; - /** - * - */ public function handle(): void { $this->redirectLoggingToStdout('cron'); diff --git a/app/Console/Cron/Weekly.php b/app/Console/Cron/Weekly.php index d41c021d..4109d127 100644 --- a/app/Console/Cron/Weekly.php +++ b/app/Console/Cron/Weekly.php @@ -10,8 +10,6 @@ use App\Events\CronWeekly; * listeners, etc can just be called to run those tasks. * * The actual cron tasks are in app/Cron - * - * @package App\Console\Cron */ class Weekly extends Command { @@ -19,9 +17,6 @@ class Weekly extends Command protected $description = 'Run the weekly cron tasks'; protected $schedule; - /** - * - */ public function handle(): void { $this->redirectLoggingToStdout('cron'); diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 0e56bb88..76008907 100755 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -11,7 +11,6 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel; /** * Class Kernel - * @package App\Console */ class Kernel extends ConsoleKernel { @@ -27,7 +26,9 @@ class Kernel extends ConsoleKernel /** * Define the application's command schedule. - * @param \Illuminate\Console\Scheduling\Schedule $schedule + * + * @param \Illuminate\Console\Scheduling\Schedule $schedule + * * @return void */ protected function schedule(Schedule $schedule): void @@ -40,6 +41,7 @@ class Kernel extends ConsoleKernel /** * Register the Closure based commands for the application. + * * @return void */ protected function commands(): void diff --git a/app/Console/Logger.php b/app/Console/Logger.php index c1945a31..aa64354f 100644 --- a/app/Console/Logger.php +++ b/app/Console/Logger.php @@ -6,13 +6,13 @@ use Monolog\Handler\StreamHandler; /** * Just a simple custom logger that dumps to the console - * @package App\Console */ class Logger { public function __invoke(array $config) { $logger = new \Monolog\Logger('console'); + try { $logger->pushHandler(new StreamHandler('php://stdout')); } catch (\Exception $e) { diff --git a/app/Console/Services/Database.php b/app/Console/Services/Database.php index 222787d4..aa1dae51 100644 --- a/app/Console/Services/Database.php +++ b/app/Console/Services/Database.php @@ -2,20 +2,20 @@ namespace App\Console\Services; -use PDOException; use PDO; /** * Class Database - * @package App\Console\Services */ class Database { /** * Create the base connection DSN, optionally include the DB name + * * @param $host * @param $port * @param null $name + * * @return string */ public function createDsn($host, $port, $name = null) @@ -33,8 +33,10 @@ class Database * @param $dsn * @param $user * @param $pass - * @return PDO + * * @throws \PDOException + * + * @return PDO */ public function createPDO($dsn, $user, $pass) { diff --git a/app/Console/Services/Importer.php b/app/Console/Services/Importer.php index 69b96c4d..305868be 100644 --- a/app/Console/Services/Importer.php +++ b/app/Console/Services/Importer.php @@ -15,17 +15,16 @@ use App\Models\Rank; use App\Models\Subfleet; use App\Models\User; use Carbon\Carbon; -use PDOException; use Illuminate\Database\QueryException; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Str; use PDO; +use PDOException; use Symfony\Component\Console\Output\ConsoleOutput; /** * Class Importer * TODO: Batch import - * @package App\Console\Services */ class Importer { @@ -36,6 +35,7 @@ class Importer /** * Hold the PDO connection to the old database + * * @var */ private $conn; @@ -47,6 +47,7 @@ class Importer /** * Hold the instance of the console logger + * * @var */ private $log; @@ -54,12 +55,12 @@ class Importer /** * CONSTANTS */ - const BATCH_READ_ROWS = 300; - const SUBFLEET_NAME = 'Imported Aircraft'; + const SUBFLEET_NAME = 'Imported Aircraft'; /** * Importer constructor. + * * @param $db_creds */ public function __construct($db_creds) @@ -67,14 +68,14 @@ class Importer // Setup the logger $this->log = new ConsoleOutput(); - # The db credentials + // The db credentials $this->creds = array_merge([ 'host' => '127.0.0.1', 'port' => 3306, 'name' => '', 'user' => '', 'pass' => '', - 'table_prefix' => 'phpvms_' + 'table_prefix' => 'phpvms_', ], $db_creds); } @@ -85,7 +86,7 @@ class Importer { $this->reconnect(); - # Import all the different parts + // Import all the different parts $this->importRanks(); $this->importAirlines(); $this->importAircraft(); @@ -95,7 +96,7 @@ class Importer $this->importFlights(); $this->importPireps(); - # Finish up + // Finish up $this->findLastPireps(); $this->recalculateRanks(); } @@ -108,7 +109,7 @@ class Importer $dsn = 'mysql:'.implode(';', [ 'host='.$this->creds['host'], 'port='.$this->creds['port'], - 'dbname='.$this->creds['name'] + 'dbname='.$this->creds['name'], ]); $this->info('Connection string: '.$dsn); @@ -152,7 +153,9 @@ class Importer /** * Return the table name with the prefix + * * @param $table + * * @return string */ protected function tableName($table) @@ -165,8 +168,8 @@ class Importer } /** - * * @param \Illuminate\Database\Eloquent\Model $model + * * @return bool */ protected function saveModel($model) @@ -186,6 +189,7 @@ class Importer /** * Create a new mapping between an old ID and the new one + * * @param $entity * @param $old_id * @param $new_id @@ -201,8 +205,10 @@ class Importer /** * Return the ID for a mapping + * * @param $entity * @param $old_id + * * @return bool */ protected function getMapping($entity, $old_id) @@ -221,6 +227,7 @@ class Importer /** * @param $date + * * @return Carbon */ protected function parseDate($date) @@ -232,7 +239,9 @@ class Importer /** * Take a decimal duration and convert it to minutes + * * @param $duration + * * @return float|int */ protected function convertDuration($duration) @@ -242,7 +251,7 @@ class Importer } elseif (strpos($duration, ':')) { $delim = ':'; } else { - # no delimiter, assume it's just a straight hour + // no delimiter, assume it's just a straight hour return (int) $duration * 60; } @@ -255,6 +264,7 @@ class Importer /** * @param $table + * * @return mixed */ protected function getTotalRows($table) @@ -271,8 +281,10 @@ class Importer /** * Read all the rows in a table, but read them in a batched manner + * * @param string $table The name of the table * @param null $read_rows Number of rows to read + * * @return \Generator */ protected function readRows($table, $read_rows = null) @@ -318,6 +330,7 @@ class Importer /** * Return the subfleet + * * @return mixed */ protected function getSubfleet() @@ -332,10 +345,8 @@ class Importer } /** - * * All the individual importers, done on a per-table basis * Some tables get saved locally for tables that use FK refs - * */ /** @@ -356,7 +367,7 @@ class Importer $this->addMapping('ranks', $row->rank, $rank->id); if ($rank->wasRecentlyCreated) { - ++$count; + $count++; } } @@ -382,7 +393,7 @@ class Importer $this->addMapping('airlines', $row->code, $airline->id); if ($airline->wasRecentlyCreated) { - ++$count; + $count++; } } @@ -406,13 +417,13 @@ class Importer ['name' => $row->fullname, 'registration' => $row->registration], ['icao' => $row->icao, 'subfleet_id' => $subfleet->id, - 'active' => $row->enabled + 'active' => $row->enabled, ]); $this->addMapping('aircraft', $row->id, $aircraft->id); if ($aircraft->wasRecentlyCreated) { - ++$count; + $count++; } } @@ -444,7 +455,7 @@ class Importer ); if ($airport->wasRecentlyCreated) { - ++$count; + $count++; } } @@ -483,7 +494,7 @@ class Importer $attrs ); } catch (\Exception $e) { - #$this->error($e); + //$this->error($e); } $this->addMapping('flights', $row->id, $flight->id); @@ -491,7 +502,7 @@ class Importer // TODO: deserialize route_details into ACARS table if ($flight->wasRecentlyCreated) { - ++$count; + $count++; } } @@ -513,7 +524,7 @@ class Importer $aircraft_id = $this->getMapping('aircraft', $row->aircraft); $attrs = [ - #'id' => $pirep_id, + //'id' => $pirep_id, 'user_id' => $user_id, 'airline_id' => $airline_id, 'aircraft_id' => $aircraft_id, @@ -527,24 +538,24 @@ class Importer 'updated_at' => $this->parseDate($row->modifieddate), ]; - # Set the distance + // Set the distance $distance = round($row->distance ?: 0, 2); $attrs['distance'] = $distance; $attrs['planned_distance'] = $distance; - # Set the flight time properly + // Set the flight time properly $duration = $this->convertDuration($row->flighttime_stamp); $attrs['flight_time'] = $duration; $attrs['planned_flight_time'] = $duration; - # Set how it was filed + // Set how it was filed if (strtoupper($row->source) === 'MANUAL') { $attrs['source'] = PirepSource::MANUAL; } else { $attrs['source'] = PirepSource::ACARS; } - # Set the flight type + // Set the flight type $row->flighttype = strtoupper($row->flighttype); if ($row->flighttype === 'P') { $attrs['flight_type'] = FlightType::SCHED_PAX; @@ -554,7 +565,7 @@ class Importer $attrs['flight_type'] = FlightType::CHARTER_PAX_ONLY; } - # Set the flight level of the PIREP is set + // Set the flight level of the PIREP is set if (property_exists($row, 'flightlevel')) { $attrs['level'] = $row->flightlevel; } else { @@ -568,18 +579,18 @@ class Importer $source = strtoupper($row->source); if ($source === 'SMARTCARS') { - # TODO: Parse smartcars log into the acars table + // TODO: Parse smartcars log into the acars table } elseif ($source === 'KACARS') { - # TODO: Parse kACARS log into acars table + // TODO: Parse kACARS log into acars table } elseif ($source === 'XACARS') { - # TODO: Parse XACARS log into acars table + // TODO: Parse XACARS log into acars table } - # TODO: Add extra fields in as PIREP fields + // TODO: Add extra fields in as PIREP fields $this->addMapping('pireps', $row->pirepid, $pirep->id); if ($pirep->wasRecentlyCreated) { - ++$count; + $count++; } } @@ -592,7 +603,7 @@ class Importer $count = 0; foreach ($this->readRows('pilots', 50) as $row) { - # TODO: What to do about pilot ids + // TODO: What to do about pilot ids $name = $row->firstname.' '.$row->lastname; @@ -624,7 +635,7 @@ class Importer $this->addMapping('users', $row->pilotid, $user->id); if ($user->wasRecentlyCreated) { - ++$count; + $count++; } } @@ -648,7 +659,9 @@ class Importer /** * Get the user's new state from their original state + * * @param $state + * * @return int */ protected function getUserState($state) @@ -662,21 +675,20 @@ class Importer 'ACTIVE' => 0, 'INACTIVE' => 1, 'BANNED' => 2, - 'ON_LEAVE' => 3 + 'ON_LEAVE' => 3, ]; // Decide which state they will be in accordance with v7 if ($state === $phpvms_classic_states['ACTIVE']) { return UserState::ACTIVE; } elseif ($state === $phpvms_classic_states['INACTIVE']) { - # TODO: Make an inactive state? + // TODO: Make an inactive state? return UserState::REJECTED; } elseif ($state === $phpvms_classic_states['BANNED']) { return UserState::SUSPENDED; } elseif ($state === $phpvms_classic_states['ON_LEAVE']) { return UserState::ON_LEAVE; - } else { - $this->error('Unknown status: '.$state); } + $this->error('Unknown status: '.$state); } } diff --git a/app/Cron/Hourly/RemoveExpiredBids.php b/app/Cron/Hourly/RemoveExpiredBids.php index 319018a0..f3e942db 100644 --- a/app/Cron/Hourly/RemoveExpiredBids.php +++ b/app/Cron/Hourly/RemoveExpiredBids.php @@ -9,18 +9,19 @@ use Carbon\Carbon; /** * Remove expired bids - * @package App\Listeners\Cron\Hourly */ class RemoveExpiredBids extends Listener { /** * Remove expired bids + * * @param CronHourly $event + * * @throws \Exception */ public function handle(CronHourly $event): void { - if(setting('bids.expire_time') === 0) { + if (setting('bids.expire_time') === 0) { return; } diff --git a/app/Cron/Monthly/ApplyExpenses.php b/app/Cron/Monthly/ApplyExpenses.php index 619ed5ae..6acfd942 100644 --- a/app/Cron/Monthly/ApplyExpenses.php +++ b/app/Cron/Monthly/ApplyExpenses.php @@ -9,7 +9,6 @@ use App\Services\Finance\RecurringFinanceService; /** * Go through and apply any finances that are daily - * @package App\Listeners\Cron\Nightly */ class ApplyExpenses extends Listener { @@ -17,6 +16,7 @@ class ApplyExpenses extends Listener /** * ApplyExpenses constructor. + * * @param RecurringFinanceService $financeSvc */ public function __construct(RecurringFinanceService $financeSvc) @@ -26,7 +26,9 @@ class ApplyExpenses extends Listener /** * Apply all of the expenses for a month + * * @param CronMonthly $event + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException * @throws \Prettus\Validator\Exceptions\ValidatorException diff --git a/app/Cron/Nightly/ApplyExpenses.php b/app/Cron/Nightly/ApplyExpenses.php index 22307cb4..1d30a0f5 100644 --- a/app/Cron/Nightly/ApplyExpenses.php +++ b/app/Cron/Nightly/ApplyExpenses.php @@ -9,7 +9,6 @@ use App\Services\Finance\RecurringFinanceService; /** * Go through and apply any finances that are daily - * @package App\Listeners\Cron\Nightly */ class ApplyExpenses extends Listener { @@ -17,6 +16,7 @@ class ApplyExpenses extends Listener /** * ApplyExpenses constructor. + * * @param RecurringFinanceService $financeSvc */ public function __construct(RecurringFinanceService $financeSvc) @@ -26,7 +26,9 @@ class ApplyExpenses extends Listener /** * Apply all of the expenses for a day + * * @param CronNightly $event + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException * @throws \Prettus\Validator\Exceptions\ValidatorException diff --git a/app/Cron/Nightly/PilotLeave.php b/app/Cron/Nightly/PilotLeave.php index 8128c69c..78c6ffd1 100644 --- a/app/Cron/Nightly/PilotLeave.php +++ b/app/Cron/Nightly/PilotLeave.php @@ -11,7 +11,6 @@ use Carbon\Carbon; /** * Determine if any pilots should be set to ON LEAVE status - * @package App\Listeners\Cron\Nightly */ class PilotLeave extends Listener { @@ -27,13 +26,15 @@ class PilotLeave extends Listener /** * Set any users to being on leave after X days + * * @param CronNightly $event + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException */ public function handle(CronNightly $event): void { - if(setting('pilots.auto_leave_days') === 0) { + if (setting('pilots.auto_leave_days') === 0) { return; } @@ -41,7 +42,7 @@ class PilotLeave extends Listener $users = User::where('status', UserState::ACTIVE) ->whereDate('updated_at', '<', $date); - foreach($users as $user) { + foreach ($users as $user) { Log::info('Setting user '.$user->ident.' to ON LEAVE status'); $this->userSvc->setStatusOnLeave($user); } diff --git a/app/Cron/Nightly/RecalculateBalances.php b/app/Cron/Nightly/RecalculateBalances.php index b713ee55..b78103fd 100644 --- a/app/Cron/Nightly/RecalculateBalances.php +++ b/app/Cron/Nightly/RecalculateBalances.php @@ -10,7 +10,6 @@ use Log; /** * This recalculates the balances on all of the journals - * @package App\Listeners\Cron */ class RecalculateBalances extends Listener { @@ -18,6 +17,7 @@ class RecalculateBalances extends Listener /** * Nightly constructor. + * * @param JournalRepository $journalRepo */ public function __construct(JournalRepository $journalRepo) @@ -27,7 +27,9 @@ class RecalculateBalances extends Listener /** * Recalculate all the balances for the different ledgers + * * @param CronNightly $event + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException */ diff --git a/app/Cron/Nightly/RecalculateStats.php b/app/Cron/Nightly/RecalculateStats.php index 71947836..84cdfac0 100644 --- a/app/Cron/Nightly/RecalculateStats.php +++ b/app/Cron/Nightly/RecalculateStats.php @@ -5,19 +5,17 @@ namespace App\Cron\Nightly; use App\Events\CronNightly; use App\Interfaces\Listener; use App\Models\Enums\UserState; -use App\Models\Journal; use App\Repositories\UserRepository; use App\Services\UserService; use Log; /** * This recalculates the balances on all of the journals - * @package App\Listeners\Cron */ class RecalculateStats extends Listener { - private $userRepo, - $userSvc; + private $userRepo; + private $userSvc; public function __construct(UserRepository $userRepo, UserService $userService) { @@ -27,7 +25,9 @@ class RecalculateStats extends Listener /** * Recalculate the stats for active users + * * @param CronNightly $event + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException */ @@ -36,7 +36,7 @@ class RecalculateStats extends Listener Log::info('Recalculating balances'); $w = [ - ['state', '!=', UserState::REJECTED] + ['state', '!=', UserState::REJECTED], ]; $users = $this->userRepo->findWhere($w, ['id', 'name', 'airline_id']); diff --git a/app/Cron/Nightly/SetActiveFlights.php b/app/Cron/Nightly/SetActiveFlights.php index c68b96a0..311d89d5 100644 --- a/app/Cron/Nightly/SetActiveFlights.php +++ b/app/Cron/Nightly/SetActiveFlights.php @@ -11,7 +11,6 @@ use Illuminate\Support\Facades\Log; /** * Figure out what flights need to be active for today - * @package App\Cron\Nightly */ class SetActiveFlights extends Listener { @@ -38,7 +37,7 @@ class SetActiveFlights extends Listener /** * @var Flight $flight */ - foreach($flights as $flight) { + foreach ($flights as $flight) { if (!$flight->active) { continue; } @@ -73,8 +72,8 @@ class SetActiveFlights extends Listener if ($today->gte($flight->start_date) && $today->lte($flight->end_date)) { if ($flight->days !== null && $flight->days > 0) { $visible = Days::isToday($flight->days); - if($flight->visible !== $visible) { - Log::info('Toggling flight '.$flight->ident.' to '.($visible?'shown':'hidden').''); + if ($flight->visible !== $visible) { + Log::info('Toggling flight '.$flight->ident.' to '.($visible ? 'shown' : 'hidden').''); $flight->visible = $visible; if ($visible === false) { diff --git a/app/Database/factories/AircraftFactory.php b/app/Database/factories/AircraftFactory.php index 25453ed4..17062581 100644 --- a/app/Database/factories/AircraftFactory.php +++ b/app/Database/factories/AircraftFactory.php @@ -4,11 +4,11 @@ use Faker\Generator as Faker; $factory->define(App\Models\Aircraft::class, function (Faker $faker) { return [ - 'id' => null, - 'subfleet_id' => function () { + 'id' => null, + 'subfleet_id' => function () { return factory(App\Models\Subfleet::class)->create()->id; }, - 'airport_id' => function () { + 'airport_id' => function () { return factory(App\Models\Airport::class)->create()->id; }, 'iata' => $faker->unique()->text(5), diff --git a/app/Database/factories/AirlineFactory.php b/app/Database/factories/AirlineFactory.php index 143ccf81..25224b74 100644 --- a/app/Database/factories/AirlineFactory.php +++ b/app/Database/factories/AirlineFactory.php @@ -3,23 +3,23 @@ use Faker\Generator as Faker; use Hashids\Hashids; -/** +/* * Add any number of airports. Don't really care if they're real or not */ $factory->define(App\Models\Airline::class, function (Faker $faker) { return [ - 'id' => null, - 'icao' => function (array $apt) use ($faker) { + 'id' => null, + 'icao' => function (array $apt) use ($faker) { $hashids = new Hashids(microtime(), 5); $mt = str_replace('.', '', microtime(true)); return $hashids->encode($mt); }, - 'iata' => function (array $apt) { + 'iata' => function (array $apt) { return $apt['icao']; }, 'name' => $faker->sentence(3), 'country' => $faker->country, - 'active' => 1 + 'active' => 1, ]; }); diff --git a/app/Database/factories/AirportFactory.php b/app/Database/factories/AirportFactory.php index a1b686d0..1909a8f5 100644 --- a/app/Database/factories/AirportFactory.php +++ b/app/Database/factories/AirportFactory.php @@ -2,7 +2,7 @@ use Faker\Generator as Faker; -/** +/* * Add any number of airports. Don't really care if they're real or not */ $factory->define(App\Models\Airport::class, function (Faker $faker) { @@ -17,10 +17,10 @@ $factory->define(App\Models\Airport::class, function (Faker $faker) { return $string; }, - 'icao' => function (array $apt) { + 'icao' => function (array $apt) { return $apt['id']; }, - 'iata' => function (array $apt) { + 'iata' => function (array $apt) { return $apt['id']; }, 'name' => $faker->sentence(3), diff --git a/app/Database/factories/FareFactory.php b/app/Database/factories/FareFactory.php index 634e573f..56e8ee78 100644 --- a/app/Database/factories/FareFactory.php +++ b/app/Database/factories/FareFactory.php @@ -4,11 +4,11 @@ use Faker\Generator as Faker; $factory->define(App\Models\Fare::class, function (Faker $faker) { return [ - 'id' => null, - 'code' => $faker->unique()->text(50), - 'name' => $faker->text(50), - 'price' => $faker->randomFloat(2, 100, 1000), - 'cost' => function (array $fare) { + 'id' => null, + 'code' => $faker->unique()->text(50), + 'name' => $faker->text(50), + 'price' => $faker->randomFloat(2, 100, 1000), + 'cost' => function (array $fare) { return round($fare['price'] / 2); }, 'capacity' => $faker->randomFloat(0, 20, 500), diff --git a/app/Database/factories/FlightFactory.php b/app/Database/factories/FlightFactory.php index 63b5e3bf..327ba2f4 100644 --- a/app/Database/factories/FlightFactory.php +++ b/app/Database/factories/FlightFactory.php @@ -2,13 +2,12 @@ /** * Create flights */ - use Faker\Generator as Faker; $factory->define(App\Models\Flight::class, function (Faker $faker) { return [ - 'id' => $faker->unique()->numberBetween(10, 10000000), - 'airline_id' => function () { + 'id' => $faker->unique()->numberBetween(10, 10000000), + 'airline_id' => function () { return factory(App\Models\Airline::class)->create()->id; }, 'flight_number' => $faker->unique()->numberBetween(10, 1000000), @@ -23,20 +22,20 @@ $factory->define(App\Models\Flight::class, function (Faker $faker) { 'alt_airport_id' => function () { return factory(App\Models\Airport::class)->create()->id; }, - 'distance' => $faker->numberBetween(0, 3000), - 'route' => null, - 'level' => 0, - 'dpt_time' => $faker->time(), - 'arr_time' => $faker->time(), - 'flight_time' => $faker->numberBetween(60, 360), - 'has_bid' => false, - 'active' => true, - 'visible' => true, - 'days' => 0, - 'start_date' => null, - 'end_date' => null, - 'created_at' => $faker->dateTimeBetween('-1 week', 'now'), - 'updated_at' => function (array $flight) { + 'distance' => $faker->numberBetween(0, 3000), + 'route' => null, + 'level' => 0, + 'dpt_time' => $faker->time(), + 'arr_time' => $faker->time(), + 'flight_time' => $faker->numberBetween(60, 360), + 'has_bid' => false, + 'active' => true, + 'visible' => true, + 'days' => 0, + 'start_date' => null, + 'end_date' => null, + 'created_at' => $faker->dateTimeBetween('-1 week', 'now'), + 'updated_at' => function (array $flight) { return $flight['created_at']; }, ]; diff --git a/app/Database/factories/JournalTransactionsFactory.php b/app/Database/factories/JournalTransactionsFactory.php index a46d2693..55c80b9b 100644 --- a/app/Database/factories/JournalTransactionsFactory.php +++ b/app/Database/factories/JournalTransactionsFactory.php @@ -8,10 +8,10 @@ $factory->define(App\Models\JournalTransactions::class, function (Faker $faker) 'journal_id' => function () { return factory(App\Models\Journal::class)->create()->id; }, - 'credit' => $faker->numberBetween(100, 10000), - 'debit' => $faker->numberBetween(100, 10000), - 'currency' => 'USD', - 'memo' => $faker->sentence(6), - 'post_date' => \Carbon\Carbon::now(), + 'credit' => $faker->numberBetween(100, 10000), + 'debit' => $faker->numberBetween(100, 10000), + 'currency' => 'USD', + 'memo' => $faker->sentence(6), + 'post_date' => \Carbon\Carbon::now(), ]; }); diff --git a/app/Database/factories/NewsFactory.php b/app/Database/factories/NewsFactory.php index eda10901..1e0c6adb 100644 --- a/app/Database/factories/NewsFactory.php +++ b/app/Database/factories/NewsFactory.php @@ -5,7 +5,7 @@ use Faker\Generator as Faker; $factory->define(App\Models\News::class, function (Faker $faker) { return [ 'id' => null, - 'user_id' => function() { + 'user_id' => function () { return factory(App\Models\User::class)->create()->id; }, 'subject' => $faker->text(), diff --git a/app/Database/factories/PirepFactory.php b/app/Database/factories/PirepFactory.php index e7e94611..e08aeb82 100644 --- a/app/Database/factories/PirepFactory.php +++ b/app/Database/factories/PirepFactory.php @@ -3,32 +3,32 @@ use Carbon\Carbon; use Faker\Generator as Faker; -/** +/* * Create a new PIREP */ $factory->define(App\Models\Pirep::class, function (Faker $faker) { return [ - 'id' => $faker->unique()->numberBetween(10, 10000000), - 'airline_id' => function () { + 'id' => $faker->unique()->numberBetween(10, 10000000), + 'airline_id' => function () { return factory(App\Models\Airline::class)->create()->id; }, - 'user_id' => function () { + 'user_id' => function () { return factory(App\Models\User::class)->create()->id; }, - 'aircraft_id' => function () { + 'aircraft_id' => function () { return factory(App\Models\Aircraft::class)->create()->id; }, - 'flight_number' => function (array $pirep) { + 'flight_number' => function (array $pirep) { return factory(App\Models\Flight::class)->create([ - 'airline_id' => $pirep['airline_id'] + 'airline_id' => $pirep['airline_id'], ])->flight_number; }, - 'route_code' => null, - 'route_leg' => null, - 'dpt_airport_id' => function () { + 'route_code' => null, + 'route_leg' => null, + 'dpt_airport_id' => function () { return factory(App\Models\Airport::class)->create()->id; }, - 'arr_airport_id' => function () { + 'arr_airport_id' => function () { return factory(App\Models\Airport::class)->create()->id; }, 'level' => $faker->numberBetween(20, 400), @@ -43,15 +43,15 @@ $factory->define(App\Models\Pirep::class, function (Faker $faker) { 'block_off_time' => function (array $pirep) { return $pirep['block_on_time']->subMinutes($pirep['flight_time']); }, - 'route' => $faker->text(200), - 'notes' => $faker->text(200), - 'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]), - 'source_name' => 'Test Factory', - 'state' => PirepState::PENDING, - 'status' => PirepStatus::SCHEDULED, - 'submitted_at' => Carbon::now('UTC')->toDateTimeString(), - 'created_at' => Carbon::now('UTC')->toDateTimeString(), - 'updated_at' => function (array $pirep) { + 'route' => $faker->text(200), + 'notes' => $faker->text(200), + 'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]), + 'source_name' => 'Test Factory', + 'state' => PirepState::PENDING, + 'status' => PirepStatus::SCHEDULED, + 'submitted_at' => Carbon::now('UTC')->toDateTimeString(), + 'created_at' => Carbon::now('UTC')->toDateTimeString(), + 'updated_at' => function (array $pirep) { return $pirep['created_at']; }, ]; diff --git a/app/Database/factories/SubfleetFactory.php b/app/Database/factories/SubfleetFactory.php index 3fa500e6..d4e24459 100644 --- a/app/Database/factories/SubfleetFactory.php +++ b/app/Database/factories/SubfleetFactory.php @@ -4,8 +4,8 @@ use Faker\Generator as Faker; $factory->define(App\Models\Subfleet::class, function (Faker $faker) { return [ - 'id' => null, - 'airline_id' => function () { + 'id' => null, + 'airline_id' => function () { return factory(App\Models\Airline::class)->create()->id; }, 'name' => $faker->unique()->text(50), diff --git a/app/Database/factories/UserFactory.php b/app/Database/factories/UserFactory.php index f8a5d206..a6ae14f0 100644 --- a/app/Database/factories/UserFactory.php +++ b/app/Database/factories/UserFactory.php @@ -7,12 +7,12 @@ $factory->define(App\Models\User::class, function (Faker $faker) { static $password; return [ - 'id' => null, - 'name' => $faker->name, - 'email' => $faker->safeEmail, - 'password' => $password ?: $password = Hash::make('secret'), - 'api_key' => $faker->sha1, - 'airline_id' => function () { + 'id' => null, + 'name' => $faker->name, + 'email' => $faker->safeEmail, + 'password' => $password ?: $password = Hash::make('secret'), + 'api_key' => $faker->sha1, + 'airline_id' => function () { return factory(App\Models\Airline::class)->create()->id; }, 'rank_id' => 1, diff --git a/app/Database/migrations/2017_06_07_014930_create_settings_table.php b/app/Database/migrations/2017_06_07_014930_create_settings_table.php index b70fe1b5..19d5de55 100644 --- a/app/Database/migrations/2017_06_07_014930_create_settings_table.php +++ b/app/Database/migrations/2017_06_07_014930_create_settings_table.php @@ -30,7 +30,7 @@ class CreateSettingsTable extends Migration $table->timestamps(); }); - /** + /* * Initial default settings */ @@ -122,7 +122,7 @@ class CreateSettingsTable extends Migration 'description' => 'The units for temperature', ]); - /** + /* * ACARS Settings */ @@ -151,7 +151,7 @@ class CreateSettingsTable extends Migration 'description' => 'Initial zoom level on the map', ]); - /** + /* * BIDS */ @@ -179,7 +179,7 @@ class CreateSettingsTable extends Migration 'description' => 'Number of hours to expire bids after', ]); - /** + /* * PIREPS */ @@ -223,7 +223,7 @@ class CreateSettingsTable extends Migration 'description' => 'When a PIREP is accepted, remove the bid, if it exists', ]); - /** + /* * PILOTS */ diff --git a/app/Database/migrations/2017_06_08_0001_roles_permissions_tables.php b/app/Database/migrations/2017_06_08_0001_roles_permissions_tables.php index 63292b47..1116927d 100644 --- a/app/Database/migrations/2017_06_08_0001_roles_permissions_tables.php +++ b/app/Database/migrations/2017_06_08_0001_roles_permissions_tables.php @@ -8,7 +8,7 @@ class RolesPermissionsTables extends Migration /** * Run the migrations. * - * @return void + * @return void */ public function up() { @@ -67,7 +67,7 @@ class RolesPermissionsTables extends Migration $table->primary(['permission_id', 'role_id']); }); - # create a default user/role + // create a default user/role $roles = [ [ 'id' => 1, @@ -77,7 +77,7 @@ class RolesPermissionsTables extends Migration [ 'id' => 2, 'name' => 'user', - 'display_name' => 'Pilot' + 'display_name' => 'Pilot', ], ]; @@ -87,7 +87,7 @@ class RolesPermissionsTables extends Migration /** * Reverse the migrations. * - * @return void + * @return void */ public function down() { diff --git a/app/Database/migrations/2017_06_17_214650_create_flight_tables.php b/app/Database/migrations/2017_06_17_214650_create_flight_tables.php index a3f8b7b1..ce534c27 100644 --- a/app/Database/migrations/2017_06_17_214650_create_flight_tables.php +++ b/app/Database/migrations/2017_06_17_214650_create_flight_tables.php @@ -57,7 +57,7 @@ class CreateFlightTables extends Migration $table->primary(['flight_id', 'fare_id']); }); - /** + /* * Hold a master list of fields */ Schema::create('flight_fields', function (Blueprint $table) { @@ -66,7 +66,7 @@ class CreateFlightTables extends Migration $table->string('slug', 50)->nullable(); }); - /** + /* * The values for the actual fields */ Schema::create('flight_field_values', function (Blueprint $table) { diff --git a/app/Database/migrations/2017_06_21_165410_create_ranks_table.php b/app/Database/migrations/2017_06_21_165410_create_ranks_table.php index a4dd72f4..a4568167 100644 --- a/app/Database/migrations/2017_06_21_165410_create_ranks_table.php +++ b/app/Database/migrations/2017_06_21_165410_create_ranks_table.php @@ -39,7 +39,7 @@ class CreateRanksTable extends Migration 'hours' => 0, 'acars_base_pay_rate' => 50, 'manual_base_pay_rate' => 25, - ] + ], ]; $this->addData('ranks', $ranks); diff --git a/app/Database/migrations/2017_12_20_004147_create_navdata_tables.php b/app/Database/migrations/2017_12_20_004147_create_navdata_tables.php index 898f4f10..b4f59c19 100644 --- a/app/Database/migrations/2017_12_20_004147_create_navdata_tables.php +++ b/app/Database/migrations/2017_12_20_004147_create_navdata_tables.php @@ -13,7 +13,7 @@ class CreateNavdataTables extends Migration */ public function up() { - /** + /* * See for defs, modify/update based on this * https://github.com/skiselkov/openfmc/blob/master/airac.h */ diff --git a/app/Database/migrations/2018_01_28_180522_create_awards_table.php b/app/Database/migrations/2018_01_28_180522_create_awards_table.php index 4f0daf8a..03ef0a5e 100644 --- a/app/Database/migrations/2018_01_28_180522_create_awards_table.php +++ b/app/Database/migrations/2018_01_28_180522_create_awards_table.php @@ -19,11 +19,11 @@ class CreateAwardsTable extends Migration $table->text('description')->nullable(); $table->text('image_url')->nullable(); - # ref fields are expenses tied to some model object - # EG, the airports has an internal expense for gate costs + // ref fields are expenses tied to some model object + // EG, the airports has an internal expense for gate costs $table->string('ref_model')->nullable(); $table->text('ref_model_params')->nullable(); - #$table->string('ref_model_id', 36)->nullable(); + //$table->string('ref_model_id', 36)->nullable(); $table->timestamps(); diff --git a/app/Database/migrations/2018_02_26_185121_create_expenses_table.php b/app/Database/migrations/2018_02_26_185121_create_expenses_table.php index 0b217791..1c43086f 100644 --- a/app/Database/migrations/2018_02_26_185121_create_expenses_table.php +++ b/app/Database/migrations/2018_02_26_185121_create_expenses_table.php @@ -19,8 +19,8 @@ class CreateExpensesTable extends Migration $table->boolean('multiplier')->nullable()->default(0); $table->boolean('active')->nullable()->default(true); - # ref fields are expenses tied to some model object - # EG, the airports has an internal expense for gate costs + // ref fields are expenses tied to some model object + // EG, the airports has an internal expense for gate costs $table->string('ref_model')->nullable(); $table->string('ref_model_id', 36)->nullable(); diff --git a/app/Database/migrations/2018_04_01_193443_create_files_table.php b/app/Database/migrations/2018_04_01_193443_create_files_table.php index f275fbef..2a4cd308 100644 --- a/app/Database/migrations/2018_04_01_193443_create_files_table.php +++ b/app/Database/migrations/2018_04_01_193443_create_files_table.php @@ -1,13 +1,14 @@ [ 'status' => $status_code, 'message' => $message, - ] + ], ]; } /** * Render an exception into an HTTP response. * - * @param \Illuminate\Http\Request $request - * @param \Exception $exception + * @param \Illuminate\Http\Request $request + * @param \Exception $exception + * * @return mixed */ public function render($request, Exception $exception) @@ -76,7 +81,7 @@ class Handler extends ExceptionHandler $error = $this->createError(404, $exception->getMessage()); } - # Custom exceptions should be extending HttpException + // Custom exceptions should be extending HttpException elseif ($exception instanceof HttpException) { $error = $this->createError( $exception->getStatusCode(), @@ -86,7 +91,7 @@ class Handler extends ExceptionHandler $headers = $exception->getHeaders(); } - # Create the detailed errors from the validation errors + // Create the detailed errors from the validation errors elseif ($exception instanceof ValidationException) { $error_messages = []; $errors = $exception->errors(); @@ -99,13 +104,11 @@ class Handler extends ExceptionHandler $error['error']['errors'] = $errors; Log::error('Validation errors', $errors); - } - - else { + } else { $error = $this->createError(400, $exception->getMessage()); } - # Only add trace if in dev + // Only add trace if in dev if (config('app.env') === 'dev') { $error['error']['trace'] = $exception->getTrace()[0]; } @@ -124,8 +127,9 @@ class Handler extends ExceptionHandler /** * Convert an authentication exception into an unauthenticated response. * - * @param \Illuminate\Http\Request $request - * @param \Illuminate\Auth\AuthenticationException $exception + * @param \Illuminate\Http\Request $request + * @param \Illuminate\Auth\AuthenticationException $exception + * * @return \Illuminate\Http\Response */ protected function unauthenticated($request, AuthenticationException $exception) @@ -140,7 +144,9 @@ class Handler extends ExceptionHandler /** * Render the given HttpException. + * * @param HttpException $e + * * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response */ protected function renderHttpException(HttpException $e) @@ -153,7 +159,7 @@ class Handler extends ExceptionHandler ]); if (view()->exists("errors::{$status}")) { - #if (view()->exists('layouts' . config('phpvms.skin') .'.errors.' .$status)) { + //if (view()->exists('layouts' . config('phpvms.skin') .'.errors.' .$status)) { return response()->view("errors::{$status}", [ 'exception' => $e, 'SKIN_NAME' => config('phpvms.skin'), diff --git a/app/Exceptions/InternalError.php b/app/Exceptions/InternalError.php index 6013a8f4..39f2e4bb 100644 --- a/app/Exceptions/InternalError.php +++ b/app/Exceptions/InternalError.php @@ -3,14 +3,13 @@ namespace App\Exceptions; use Illuminate\Validation\ValidationException; -use Validator; use Log; +use Validator; /** * Show an internal error, bug piggyback off of the validation * exception type - this has a place to show up in the UI as a * flash message. - * @package App\Exceptions */ class InternalError extends ValidationException { @@ -19,6 +18,7 @@ class InternalError extends ValidationException /** * InternalError constructor. + * * @param string|null $message * @param null $field */ diff --git a/app/Exceptions/PirepCancelled.php b/app/Exceptions/PirepCancelled.php index 8db80e2a..61233c7a 100644 --- a/app/Exceptions/PirepCancelled.php +++ b/app/Exceptions/PirepCancelled.php @@ -6,7 +6,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException; /** * Class PirepCancelled - * @package App\Exceptions */ class PirepCancelled extends HttpException { diff --git a/app/Exceptions/SettingNotFound.php b/app/Exceptions/SettingNotFound.php index f5030f84..589f1cd4 100644 --- a/app/Exceptions/SettingNotFound.php +++ b/app/Exceptions/SettingNotFound.php @@ -6,7 +6,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException; /** * Class SettingNotFound - * @package App\Exceptions */ class SettingNotFound extends HttpException { diff --git a/app/Exceptions/UserNotAtAirport.php b/app/Exceptions/UserNotAtAirport.php index 5ec73ee5..ef65c3ea 100644 --- a/app/Exceptions/UserNotAtAirport.php +++ b/app/Exceptions/UserNotAtAirport.php @@ -2,10 +2,8 @@ namespace App\Exceptions; - /** * Class UserNotAtAirport - * @package App\Exceptions */ class UserNotAtAirport extends InternalError { diff --git a/app/Facades/Utils.php b/app/Facades/Utils.php index 0c5a4d63..6a17e0bd 100644 --- a/app/Facades/Utils.php +++ b/app/Facades/Utils.php @@ -7,7 +7,6 @@ use Illuminate\Support\Facades\Facade; /** * Class Utils - * @package App\Facades */ class Utils extends Facade { @@ -21,7 +20,9 @@ class Utils extends Facade /** * Simple check on the first character if it's an object or not + * * @param $obj + * * @return bool */ public static function isObject($obj) @@ -40,10 +41,13 @@ class Utils extends Facade /** * Download a URI. If a file is given, it will save the downloaded * content into that file + * * @param $uri * @param null $file - * @return string + * * @throws \RuntimeException + * + * @return string */ public static function downloadUrl($uri, $file = null) { @@ -65,6 +69,7 @@ class Utils extends Facade /** * Returns a 40 character API key that a user can use + * * @return string */ public static function generateApiKey() @@ -89,13 +94,15 @@ class Utils extends Facade /** * Convert seconds to an array of hours, minutes, seconds + * * @param $seconds + * * @return array['h', 'm', 's'] */ public static function secondsToTimeParts($seconds): array { - $dtF = new \DateTime('@0', new \DateTimeZone('UTC')); - $dtT = new \DateTime("@$seconds", new \DateTimeZone('UTC')); + $dtF = new \DateTimeImmutable('@0', new \DateTimeZone('UTC')); + $dtT = new \DateTimeImmutable("@$seconds", new \DateTimeZone('UTC')); $t = $dtF->diff($dtT); @@ -109,8 +116,10 @@ class Utils extends Facade /** * Convert seconds to HH MM format + * * @param $seconds * @param bool $incl_sec + * * @return string */ public static function secondsToTimeString($seconds, $incl_sec = false): string @@ -126,6 +135,7 @@ class Utils extends Facade /** * @param $minutes + * * @return float|int */ public static function minutesToSeconds($minutes) @@ -135,7 +145,9 @@ class Utils extends Facade /** * Convert the seconds to minutes and then round it up + * * @param $seconds + * * @return float|int */ public static function secondsToMinutes($seconds) @@ -145,7 +157,9 @@ class Utils extends Facade /** * Convert hours to minutes. Pretty complex + * * @param $minutes + * * @return float|int */ public static function minutesToHours($minutes) @@ -156,6 +170,7 @@ class Utils extends Facade /** * @param $hours * @param null $minutes + * * @return float|int */ public static function hoursToMinutes($hours, $minutes = null) @@ -170,8 +185,10 @@ class Utils extends Facade /** * Bitwise operator for setting days of week to integer field + * * @param int $datefield initial datefield * @param array $day_enums Array of values from config("enum.days") + * * @return int */ public static function setDays(int $datefield, array $day_enums) @@ -185,8 +202,10 @@ class Utils extends Facade /** * Bit check if a day exists within a integer bitfield + * * @param int $datefield datefield from database * @param int $day_enum Value from config("enum.days") + * * @return bool */ public static function hasDay(int $datefield, int $day_enum) diff --git a/app/Http/Controllers/Admin/AircraftController.php b/app/Http/Controllers/Admin/AircraftController.php index 556fc30a..817debf3 100644 --- a/app/Http/Controllers/Admin/AircraftController.php +++ b/app/Http/Controllers/Admin/AircraftController.php @@ -16,20 +16,19 @@ use App\Services\ImportService; use Flash; use Illuminate\Http\Request; use Log; -use Prettus\Repository\Criteria\RequestCriteria; use Storage; /** * Class AircraftController - * @package App\Http\Controllers\Admin */ class AircraftController extends Controller { - private $aircraftRepo, - $importSvc; + private $aircraftRepo; + private $importSvc; /** * AircraftController constructor. + * * @param AircraftRepository $aircraftRepo * @param ImportService $importSvc */ @@ -43,16 +42,19 @@ class AircraftController extends Controller /** * Display a listing of the Aircraft. + * * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index(Request $request) { // If subfleet ID is passed part of the query string, then only // show the aircraft that are in that subfleet $w = []; - if($request->filled('subfleet')) { + if ($request->filled('subfleet')) { $w['subfleet_id'] = $request->input('subfleet'); } @@ -60,27 +62,30 @@ class AircraftController extends Controller $aircraft = $aircraft->all(); return view('admin.aircraft.index', [ - 'aircraft' => $aircraft, + 'aircraft' => $aircraft, 'subfleet_id' => $request->input('subfleet'), ]); } /** * Show the form for creating a new Aircraft. + * * @param Request $request + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function create(Request $request) { return view('admin.aircraft.create', [ - 'subfleets' => Subfleet::all()->pluck('name', 'id'), - 'statuses' => AircraftStatus::select(true), - 'subfleet_id' => $request->query('subfleet') + 'subfleets' => Subfleet::all()->pluck('name', 'id'), + 'statuses' => AircraftStatus::select(true), + 'subfleet_id' => $request->query('subfleet'), ]); } /** * Store a newly created Aircraft in storage. + * * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function store(CreateAircraftRequest $request) @@ -94,6 +99,8 @@ class AircraftController extends Controller /** * Display the specified Aircraft. + * + * @param mixed $id */ public function show($id) { @@ -111,6 +118,8 @@ class AircraftController extends Controller /** * Show the form for editing the specified Aircraft. + * + * @param mixed $id */ public function edit($id) { @@ -130,6 +139,9 @@ class AircraftController extends Controller /** * Update the specified Aircraft in storage. + * + * @param mixed $id + * * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function update($id, UpdateAircraftRequest $request) @@ -150,6 +162,8 @@ class AircraftController extends Controller /** * Remove the specified Aircraft from storage. + * + * @param mixed $id */ public function destroy($id) { @@ -168,9 +182,12 @@ class AircraftController extends Controller /** * Run the aircraft exporter + * * @param Request $request - * @return \Symfony\Component\HttpFoundation\BinaryFileResponse + * * @throws \League\Csv\Exception + * + * @return \Symfony\Component\HttpFoundation\BinaryFileResponse */ public function export(Request $request) { @@ -187,8 +204,10 @@ class AircraftController extends Controller /** * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Illuminate\Validation\ValidationException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function import(Request $request) { @@ -215,6 +234,7 @@ class AircraftController extends Controller /** * @param Aircraft|null $aircraft + * * @return mixed */ protected function return_expenses_view(Aircraft $aircraft) @@ -228,10 +248,13 @@ class AircraftController extends Controller /** * Operations for associating ranks to the subfleet + * * @param $id * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Exception + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function expenses($id, Request $request) { diff --git a/app/Http/Controllers/Admin/AirlinesController.php b/app/Http/Controllers/Admin/AirlinesController.php index 264faa29..7536a435 100644 --- a/app/Http/Controllers/Admin/AirlinesController.php +++ b/app/Http/Controllers/Admin/AirlinesController.php @@ -14,7 +14,6 @@ use Response; /** * Class AirlinesController - * @package App\Http\Controllers\Admin */ class AirlinesController extends Controller { @@ -22,14 +21,17 @@ class AirlinesController extends Controller /** * AirlinesController constructor. + * * @param AirlineRepository $airlinesRepo */ - public function __construct(AirlineRepository $airlinesRepo) { + public function __construct(AirlineRepository $airlinesRepo) + { $this->airlineRepo = $airlinesRepo; } /** * Display a listing of the Airlines. + * * @throws \Prettus\Repository\Exceptions\RepositoryException */ public function index(Request $request) @@ -54,6 +56,7 @@ class AirlinesController extends Controller /** * Store a newly created Airlines in storage. + * * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function store(CreateAirlineRequest $request) @@ -67,7 +70,9 @@ class AirlinesController extends Controller /** * Display the specified Airlines. - * @param int $id + * + * @param int $id + * * @return mixed */ public function show($id) @@ -86,7 +91,9 @@ class AirlinesController extends Controller /** * Show the form for editing the specified Airlines. - * @param int $id + * + * @param int $id + * * @return Response */ public function edit($id) @@ -106,10 +113,13 @@ class AirlinesController extends Controller /** * Update the specified Airlines in storage. - * @param int $id + * + * @param int $id * @param UpdateAirlineRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function update($id, UpdateAirlineRequest $request) { @@ -128,7 +138,9 @@ class AirlinesController extends Controller /** * Remove the specified Airlines from storage. - * @param int $id + * + * @param int $id + * * @return Response */ public function destroy($id) diff --git a/app/Http/Controllers/Admin/AirportController.php b/app/Http/Controllers/Admin/AirportController.php index b2bbd8f8..703e5d7f 100644 --- a/app/Http/Controllers/Admin/AirportController.php +++ b/app/Http/Controllers/Admin/AirportController.php @@ -21,12 +21,11 @@ use Storage; /** * Class AirportController - * @package App\Http\Controllers\Admin */ class AirportController extends Controller { - private $airportRepo, - $importSvc; + private $airportRepo; + private $importSvc; /** * @param AirportRepository $airportRepo @@ -42,9 +41,12 @@ class AirportController extends Controller /** * Display a listing of the Airport. + * * @param Request $request - * @return Response + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return Response */ public function index(Request $request) { @@ -65,6 +67,7 @@ class AirportController extends Controller /** * Show the form for creating a new Airport. + * * @return Response */ public function create() @@ -76,9 +79,12 @@ class AirportController extends Controller /** * Store a newly created Airport in storage. + * * @param CreateAirportRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function store(CreateAirportRequest $request) { @@ -93,7 +99,9 @@ class AirportController extends Controller /** * Display the specified Airport. - * @param int $id + * + * @param int $id + * * @return Response */ public function show($id) @@ -112,7 +120,9 @@ class AirportController extends Controller /** * Show the form for editing the specified Airport. - * @param int $id + * + * @param int $id + * * @return Response */ public function edit($id) @@ -132,10 +142,13 @@ class AirportController extends Controller /** * Update the specified Airport in storage. - * @param int $id + * + * @param int $id * @param UpdateAirportRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function update($id, UpdateAirportRequest $request) { @@ -157,7 +170,9 @@ class AirportController extends Controller /** * Remove the specified Airport from storage. - * @param int $id + * + * @param int $id + * * @return Response */ public function destroy($id) @@ -177,9 +192,12 @@ class AirportController extends Controller /** * Run the airport exporter + * * @param Request $request - * @return \Symfony\Component\HttpFoundation\BinaryFileResponse + * * @throws \League\Csv\Exception + * + * @return \Symfony\Component\HttpFoundation\BinaryFileResponse */ public function export(Request $request) { @@ -195,10 +213,11 @@ class AirportController extends Controller } /** - * * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Illuminate\Validation\ValidationException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function import(Request $request) { @@ -225,6 +244,7 @@ class AirportController extends Controller /** * @param Airport $airport + * * @return mixed */ protected function return_expenses_view(Airport $airport) @@ -237,10 +257,13 @@ class AirportController extends Controller /** * Operations for associating ranks to the subfleet + * * @param $id * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Exception + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function expenses($id, Request $request) { @@ -273,7 +296,9 @@ class AirportController extends Controller /** * Set fuel prices for this airport + * * @param Request $request + * * @return mixed */ public function fuel(Request $request) diff --git a/app/Http/Controllers/Admin/AwardController.php b/app/Http/Controllers/Admin/AwardController.php index 93d39be7..4d4c68ac 100755 --- a/app/Http/Controllers/Admin/AwardController.php +++ b/app/Http/Controllers/Admin/AwardController.php @@ -14,20 +14,20 @@ use Response; class AwardController extends Controller { - /** @var AwardRepository */ - private $awardRepository, - $awardSvc; + /** @var AwardRepository */ + private $awardRepository; + private $awardSvc; /** * AwardController constructor. + * * @param AwardRepository $awardRepo * @param AwardService $awardSvc */ public function __construct( AwardRepository $awardRepo, AwardService $awardSvc - ) - { + ) { $this->awardRepository = $awardRepo; $this->awardSvc = $awardSvc; } @@ -57,9 +57,12 @@ class AwardController extends Controller /** * Display a listing of the Fare. + * * @param Request $request - * @return Response + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return Response */ public function index(Request $request) { @@ -73,6 +76,7 @@ class AwardController extends Controller /** * Show the form for creating a new Fare. + * * @return Response */ public function create() @@ -87,9 +91,12 @@ class AwardController extends Controller /** * Store a newly created Fare in storage. + * * @param CreateAwardRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function store(CreateAwardRequest $request) { @@ -102,7 +109,9 @@ class AwardController extends Controller /** * Display the specified Fare. - * @param int $id + * + * @param int $id + * * @return Response */ public function show($id) @@ -121,7 +130,9 @@ class AwardController extends Controller /** * Show the form for editing the specified award. - * @param int $id + * + * @param int $id + * * @return Response */ public function edit($id) @@ -144,10 +155,13 @@ class AwardController extends Controller /** * Update the specified award in storage. - * @param int $id + * + * @param int $id * @param UpdateAwardRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function update($id, UpdateAwardRequest $request) { @@ -167,7 +181,7 @@ class AwardController extends Controller /** * Remove the specified Fare from storage. * - * @param int $id + * @param int $id * * @return Response */ diff --git a/app/Http/Controllers/Admin/DashboardController.php b/app/Http/Controllers/Admin/DashboardController.php index a74d575b..be9cba0b 100644 --- a/app/Http/Controllers/Admin/DashboardController.php +++ b/app/Http/Controllers/Admin/DashboardController.php @@ -16,16 +16,16 @@ use vierbergenlars\SemVer\version as semver; /** * Class DashboardController - * @package App\Http\Controllers\Admin */ class DashboardController extends Controller { - private $newsRepo, - $pirepRepo, - $userRepo; + private $newsRepo; + private $pirepRepo; + private $userRepo; /** * DashboardController constructor. + * * @param NewsRepository $newsRepo * @param PirepRepository $pirepRepo * @param UserRepository $userRepo @@ -44,6 +44,7 @@ class DashboardController extends Controller * Check if a new version is available by checking the VERSION file from * S3 and then using the semver library to do the comparison. Just show * a session flash file on this page that'll get cleared right away + * * @throws \RuntimeException */ protected function checkNewVersion() @@ -63,6 +64,7 @@ class DashboardController extends Controller /** * Show the admin dashboard + * * @throws \RuntimeException */ public function index(Request $request) @@ -78,8 +80,10 @@ class DashboardController extends Controller /** * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function news(Request $request) { diff --git a/app/Http/Controllers/Admin/ExpenseController.php b/app/Http/Controllers/Admin/ExpenseController.php index 92310bc3..fa622eb4 100644 --- a/app/Http/Controllers/Admin/ExpenseController.php +++ b/app/Http/Controllers/Admin/ExpenseController.php @@ -19,16 +19,16 @@ use Storage; /** * Class ExpenseController - * @package App\Http\Controllers\Admin */ class ExpenseController extends Controller { - private $airlineRepo, - $expenseRepo, - $importSvc; + private $airlineRepo; + private $expenseRepo; + private $importSvc; /** * expensesController constructor. + * * @param AirlineRepository $airlineRepo * @param ExpenseRepository $expenseRepo * @param ImportService $importSvc @@ -45,19 +45,22 @@ class ExpenseController extends Controller /** * Display a listing of the expenses. + * * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index(Request $request) { $this->expenseRepo->pushCriteria(new RequestCriteria($request)); $expenses = $this->expenseRepo->findWhere([ - 'ref_model' => Expense::class + 'ref_model' => Expense::class, ]); return view('admin.expenses.index', [ - 'expenses' => $expenses + 'expenses' => $expenses, ]); } @@ -74,9 +77,12 @@ class ExpenseController extends Controller /** * Store a newly created expenses in storage. + * * @param Request $request - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store(Request $request) { @@ -91,7 +97,9 @@ class ExpenseController extends Controller /** * Display the specified expenses. - * @param int $id + * + * @param int $id + * * @return mixed */ public function show($id) @@ -111,7 +119,9 @@ class ExpenseController extends Controller /** * Show the form for editing the specified expenses. - * @param int $id + * + * @param int $id + * * @return Response */ public function edit($id) @@ -133,10 +143,13 @@ class ExpenseController extends Controller /** * Update the specified expenses in storage. - * @param int $id + * + * @param int $id * @param Request $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function update($id, Request $request) { @@ -157,7 +170,9 @@ class ExpenseController extends Controller /** * Remove the specified expenses from storage. - * @param int $id + * + * @param int $id + * * @return Response */ public function destroy($id) @@ -177,9 +192,12 @@ class ExpenseController extends Controller /** * Run the airport exporter + * * @param Request $request - * @return \Symfony\Component\HttpFoundation\BinaryFileResponse + * * @throws \League\Csv\Exception + * + * @return \Symfony\Component\HttpFoundation\BinaryFileResponse */ public function export(Request $request) { @@ -195,10 +213,11 @@ class ExpenseController extends Controller } /** - * * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Illuminate\Validation\ValidationException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function import(Request $request) { diff --git a/app/Http/Controllers/Admin/FareController.php b/app/Http/Controllers/Admin/FareController.php index 7aa42fb3..0505614b 100644 --- a/app/Http/Controllers/Admin/FareController.php +++ b/app/Http/Controllers/Admin/FareController.php @@ -18,15 +18,15 @@ use Storage; /** * Class FareController - * @package App\Http\Controllers\Admin */ class FareController extends Controller { - private $fareRepo, - $importSvc; + private $fareRepo; + private $importSvc; /** * FareController constructor. + * * @param FareRepository $fareRepo * @param ImportService $importSvc */ @@ -40,9 +40,12 @@ class FareController extends Controller /** * Display a listing of the Fare. + * * @param Request $request - * @return Response + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return Response */ public function index(Request $request) { @@ -65,9 +68,12 @@ class FareController extends Controller /** * Store a newly created Fare in storage. + * * @param CreateFareRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function store(CreateFareRequest $request) { @@ -80,7 +86,9 @@ class FareController extends Controller /** * Display the specified Fare. - * @param int $id + * + * @param int $id + * * @return Response */ public function show($id) @@ -96,7 +104,9 @@ class FareController extends Controller /** * Show the form for editing the specified Fare. - * @param int $id + * + * @param int $id + * * @return Response */ public function edit($id) @@ -112,10 +122,13 @@ class FareController extends Controller /** * Update the specified Fare in storage. - * @param int $id + * + * @param int $id * @param UpdateFareRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function update($id, UpdateFareRequest $request) { @@ -133,7 +146,9 @@ class FareController extends Controller /** * Remove the specified Fare from storage. - * @param int $id + * + * @param int $id + * * @return Response */ public function destroy($id) @@ -152,9 +167,12 @@ class FareController extends Controller /** * Run the aircraft exporter + * * @param Request $request - * @return \Symfony\Component\HttpFoundation\BinaryFileResponse + * * @throws \League\Csv\Exception + * + * @return \Symfony\Component\HttpFoundation\BinaryFileResponse */ public function export(Request $request) { @@ -170,10 +188,11 @@ class FareController extends Controller } /** - * * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Illuminate\Validation\ValidationException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function import(Request $request) { diff --git a/app/Http/Controllers/Admin/FileController.php b/app/Http/Controllers/Admin/FileController.php index 4d5ad49b..c9627b61 100644 --- a/app/Http/Controllers/Admin/FileController.php +++ b/app/Http/Controllers/Admin/FileController.php @@ -14,7 +14,6 @@ use Validator; /** * Class FileController - * @package App\Http\Controllers\Admin */ class FileController extends Controller { @@ -27,9 +26,12 @@ class FileController extends Controller /** * Store a newly file + * * @param Request $request - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * * @throws \Hashids\HashidsException + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store(Request $request) { @@ -41,7 +43,7 @@ class FileController extends Controller $validator = Validator::make($request->all(), [ 'filename' => 'required', 'file_description' => 'nullable', - 'file' => 'required|file' + 'file' => 'required|file', ]); if ($validator->fails()) { @@ -50,7 +52,6 @@ class FileController extends Controller Log::info('Uploading files', $attrs); - $file = $request->file('file'); $this->fileSvc->saveFile($file, 'files', [ 'name' => $attrs['filename'], @@ -65,9 +66,12 @@ class FileController extends Controller /** * Remove the file from storage. + * * @param $id - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * * @throws \Exception + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function destroy($id) { diff --git a/app/Http/Controllers/Admin/FinanceController.php b/app/Http/Controllers/Admin/FinanceController.php index a9db4a90..62c65b73 100644 --- a/app/Http/Controllers/Admin/FinanceController.php +++ b/app/Http/Controllers/Admin/FinanceController.php @@ -13,14 +13,13 @@ use Illuminate\Http\Request; /** * Class FinanceController - * @package App\Http\Controllers\Admin */ class FinanceController extends Controller { private $airlineRepo; /** - * @param AirlineRepository $airlineRepo + * @param AirlineRepository $airlineRepo */ public function __construct( AirlineRepository $airlineRepo @@ -30,10 +29,13 @@ class FinanceController extends Controller /** * Display the summation tables for a given month by airline + * * @param Request $request - * @return mixed + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException + * + * @return mixed */ public function index(Request $request) { @@ -48,15 +50,15 @@ class FinanceController extends Controller $transaction_groups = []; $airlines = $this->airlineRepo->orderBy('icao')->all(); - # group by the airline + // group by the airline foreach ($airlines as $airline) { - # Return all the transactions, grouped by the transaction group + // Return all the transactions, grouped by the transaction group $transactions = JournalTransaction::groupBy('transaction_group', 'currency') ->selectRaw('transaction_group, currency, SUM(credit) as sum_credits, SUM(debit) as sum_debits') ->where([ - 'journal_id' => $airline->journal->id + 'journal_id' => $airline->journal->id, ]) ->whereBetween('created_at', $between, 'AND') ->orderBy('sum_credits', 'desc') @@ -64,7 +66,7 @@ class FinanceController extends Controller ->orderBy('transaction_group', 'asc') ->get(); - # Summate it so we can show it on the footer of the table + // Summate it so we can show it on the footer of the table $sum_all_credits = 0; $sum_all_debits = 0; foreach ($transactions as $ta) { @@ -89,6 +91,8 @@ class FinanceController extends Controller /** * Show a month + * + * @param mixed $id */ public function show($id) { diff --git a/app/Http/Controllers/Admin/FlightController.php b/app/Http/Controllers/Admin/FlightController.php index 89411211..b0299713 100644 --- a/app/Http/Controllers/Admin/FlightController.php +++ b/app/Http/Controllers/Admin/FlightController.php @@ -30,22 +30,22 @@ use Storage; /** * Class FlightController - * @package App\Http\Controllers\Admin */ class FlightController extends Controller { - private $airlineRepo, - $airportRepo, - $fareRepo, - $flightRepo, - $flightFieldRepo, - $fareSvc, - $flightSvc, - $importSvc, - $subfleetRepo; + private $airlineRepo; + private $airportRepo; + private $fareRepo; + private $flightRepo; + private $flightFieldRepo; + private $fareSvc; + private $flightSvc; + private $importSvc; + private $subfleetRepo; /** * FlightController constructor. + * * @param AirlineRepository $airlineRepo * @param AirportRepository $airportRepo * @param FareRepository $fareRepo @@ -80,6 +80,7 @@ class FlightController extends Controller /** * Save any custom fields found + * * @param Flight $flight * @param Request $request */ @@ -93,8 +94,8 @@ class FlightController extends Controller } $custom_fields[] = [ - 'name' => $field->name, - 'value' => $request->input($field->slug) + 'name' => $field->name, + 'value' => $request->input($field->slug), ]; } @@ -104,6 +105,7 @@ class FlightController extends Controller /** * @param $flight + * * @return array */ protected function getAvailSubfleets($flight) @@ -123,8 +125,10 @@ class FlightController extends Controller /** * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index(Request $request) { @@ -142,6 +146,7 @@ class FlightController extends Controller /** * Show the form for creating a new Flight. + * * @return Response */ public function create() @@ -159,8 +164,10 @@ class FlightController extends Controller /** * @param CreateFlightRequest $request - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store(CreateFlightRequest $request) { @@ -190,6 +197,7 @@ class FlightController extends Controller /** * @param $id + * * @return mixed */ public function show($id) @@ -212,6 +220,7 @@ class FlightController extends Controller /** * @param $id + * * @return mixed */ public function edit($id) @@ -244,8 +253,10 @@ class FlightController extends Controller /** * @param $id * @param UpdateFlightRequest $request - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update($id, UpdateFlightRequest $request) { @@ -258,11 +269,11 @@ class FlightController extends Controller $input = $request->all(); - # apply the updates here temporarily, don't save - # the repo->update() call will actually do it + // apply the updates here temporarily, don't save + // the repo->update() call will actually do it $flight->fill($input); - if($this->flightSvc->isFlightDuplicate($flight)) { + if ($this->flightSvc->isFlightDuplicate($flight)) { Flash::error('Duplicate flight with same number/code/leg found, please change to proceed'); return redirect()->back()->withInput($request->all()); } @@ -285,8 +296,10 @@ class FlightController extends Controller /** * @param $id - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * * @throws \Exception + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function destroy($id) { @@ -305,9 +318,12 @@ class FlightController extends Controller /** * Run the flight exporter + * * @param Request $request - * @return \Symfony\Component\HttpFoundation\BinaryFileResponse + * * @throws \League\Csv\Exception + * + * @return \Symfony\Component\HttpFoundation\BinaryFileResponse */ public function export(Request $request) { @@ -323,16 +339,17 @@ class FlightController extends Controller } /** - * * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Illuminate\Validation\ValidationException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function import(Request $request) { $logs = [ 'success' => [], - 'errors' => [], + 'errors' => [], ]; if ($request->isMethod('post')) { @@ -352,6 +369,7 @@ class FlightController extends Controller /** * @param $flight + * * @return mixed */ protected function return_fields_view($flight) @@ -366,6 +384,7 @@ class FlightController extends Controller /** * @param $flight_id * @param Request $request + * * @return mixed */ public function field_values($flight_id, Request $request) @@ -388,11 +407,11 @@ class FlightController extends Controller } elseif ($request->isMethod('put')) { Log::info('Updating flight field, flight: '.$flight_id, $request->input()); $field = FlightFieldValue::where([ - 'name' => $request->input('name'), + 'name' => $request->input('name'), 'flight_id' => $flight_id, ])->first(); - if(!$field) { + if (!$field) { Log::info('Field not found, creating new'); $field = new FlightFieldValue(); $field->name = $request->input('name'); @@ -401,11 +420,11 @@ class FlightController extends Controller $field->flight_id = $flight_id; $field->value = $request->input('value'); $field->save(); - // update the field value + // update the field value } // remove custom field from flight elseif ($request->isMethod('delete')) { Log::info('Deleting flight field, flight: '.$flight_id, $request->input()); - if($flight_id && $request->input('field_id')) { + if ($flight_id && $request->input('field_id')) { FlightFieldValue::destroy($request->input('field_id')); } } @@ -415,6 +434,7 @@ class FlightController extends Controller /** * @param $flight + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ protected function return_subfleet_view($flight) @@ -430,6 +450,7 @@ class FlightController extends Controller /** * @param $id * @param Request $request + * * @return mixed */ public function subfleets($id, Request $request) @@ -444,7 +465,7 @@ class FlightController extends Controller // add aircraft to flight $subfleet = $this->subfleetRepo->findWithoutFail($request->subfleet_id); - if(!$subfleet) { + if (!$subfleet) { return $this->return_subfleet_view($flight); } @@ -460,6 +481,8 @@ class FlightController extends Controller /** * Get all the fares that haven't been assigned to a given subfleet + * + * @param mixed $flight */ protected function getAvailFares($flight) { @@ -475,6 +498,7 @@ class FlightController extends Controller /** * @param Flight $flight + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ protected function return_fares_view(Flight $flight) @@ -489,6 +513,7 @@ class FlightController extends Controller /** * @param Request $request + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function fares(Request $request) @@ -515,7 +540,7 @@ class FlightController extends Controller 'value' => 'nullable', // regex:/([\d%]*)/ ]); - /** + /* * update specific fare data */ if ($request->isMethod('post')) { diff --git a/app/Http/Controllers/Admin/FlightFieldController.php b/app/Http/Controllers/Admin/FlightFieldController.php index 341d6466..452959fb 100644 --- a/app/Http/Controllers/Admin/FlightFieldController.php +++ b/app/Http/Controllers/Admin/FlightFieldController.php @@ -11,7 +11,6 @@ use Response; /** * Class FlightFieldController - * @package App\Http\Controllers\Admin */ class FlightFieldController extends Controller { @@ -19,6 +18,7 @@ class FlightFieldController extends Controller /** * FlightFieldController constructor. + * * @param FlightFieldRepository $flightFieldRepository */ public function __construct( @@ -29,9 +29,12 @@ class FlightFieldController extends Controller /** * Display a listing of the FlightField. + * * @param Request $request - * @return Response + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return Response */ public function index(Request $request) { @@ -45,6 +48,7 @@ class FlightFieldController extends Controller /** * Show the form for creating a new FlightField. + * * @return Response */ public function create() @@ -54,9 +58,12 @@ class FlightFieldController extends Controller /** * Store a newly created FlightField in storage. + * * @param Request $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function store(Request $request) { @@ -71,7 +78,9 @@ class FlightFieldController extends Controller /** * Display the specified FlightField. - * @param int $id + * + * @param int $id + * * @return Response */ public function show($id) @@ -90,7 +99,9 @@ class FlightFieldController extends Controller /** * Show the form for editing the specified FlightField. - * @param int $id + * + * @param int $id + * * @return Response */ public function edit($id) @@ -109,10 +120,13 @@ class FlightFieldController extends Controller /** * Update the specified FlightField in storage. + * * @param $id * @param Request $request - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update($id, Request $request) { @@ -133,7 +147,9 @@ class FlightFieldController extends Controller /** * Remove the specified FlightField from storage. - * @param int $id + * + * @param int $id + * * @return Response */ public function destroy($id) diff --git a/app/Http/Controllers/Admin/PirepController.php b/app/Http/Controllers/Admin/PirepController.php index 3f5188db..e6b5a2e9 100644 --- a/app/Http/Controllers/Admin/PirepController.php +++ b/app/Http/Controllers/Admin/PirepController.php @@ -8,7 +8,6 @@ use App\Http\Requests\UpdatePirepRequest; use App\Interfaces\Controller; use App\Models\Enums\PirepSource; use App\Models\Enums\PirepState; -use App\Models\Enums\PirepStatus; use App\Models\Pirep; use App\Models\PirepComment; use App\Repositories\AircraftRepository; @@ -31,23 +30,23 @@ use Response; /** * Class PirepController - * @package App\Http\Controllers\Admin */ class PirepController extends Controller { - private $airportRepo, - $airlineRepo, - $aircraftRepo, - $fareSvc, - $journalRepo, - $pirepSvc, - $pirepRepo, - $pirepFieldRepo, - $subfleetRepo, - $userSvc; + private $airportRepo; + private $airlineRepo; + private $aircraftRepo; + private $fareSvc; + private $journalRepo; + private $pirepSvc; + private $pirepRepo; + private $pirepFieldRepo; + private $subfleetRepo; + private $userSvc; /** * PirepController constructor. + * * @param AirportRepository $airportRepo * @param AirlineRepository $airlineRepo * @param AircraftRepository $aircraftRepo @@ -85,7 +84,9 @@ class PirepController extends Controller /** * Dropdown with aircraft grouped by subfleet + * * @param null $user + * * @return array */ public function aircraftList($user = null) @@ -112,6 +113,7 @@ class PirepController extends Controller /** * Save any custom fields found + * * @param Pirep $pirep * @param Request $request */ @@ -127,7 +129,7 @@ class PirepController extends Controller $custom_fields[] = [ 'name' => $field->name, 'value' => $request->input($field->slug), - 'source' => PirepSource::MANUAL + 'source' => PirepSource::MANUAL, ]; } @@ -137,8 +139,10 @@ class PirepController extends Controller /** * Save the fares that have been specified/saved + * * @param Pirep $pirep * @param Request $request + * * @throws \Exception */ protected function saveFares(Pirep $pirep, Request $request) @@ -163,7 +167,9 @@ class PirepController extends Controller /** * Return the fares form for a given aircraft + * * @param Request $request + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function fares(Request $request) @@ -182,8 +188,10 @@ class PirepController extends Controller /** * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index(Request $request) { @@ -194,19 +202,21 @@ class PirepController extends Controller ->whereNotInOrder('state', [ PirepState::CANCELLED, PirepState::DRAFT, - PirepState::IN_PROGRESS + PirepState::IN_PROGRESS, ], 'created_at', 'desc') ->paginate(); return view('admin.pireps.index', [ - 'pireps' => $pireps + 'pireps' => $pireps, ]); } /** * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function pending(Request $request) { @@ -219,12 +229,13 @@ class PirepController extends Controller ->paginate(); return view('admin.pireps.index', [ - 'pireps' => $pireps + 'pireps' => $pireps, ]); } /** * Show the form for creating a new Pirep. + * * @return Response */ public function create() @@ -238,9 +249,11 @@ class PirepController extends Controller /** * @param CreatePirepRequest $request - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * * @throws \Prettus\Validator\Exceptions\ValidatorException * @throws \Exception + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store(CreatePirepRequest $request) { @@ -261,7 +274,9 @@ class PirepController extends Controller /** * Display the specified Pirep. - * @param int $id + * + * @param int $id + * * @return Response */ public function show($id) @@ -280,9 +295,12 @@ class PirepController extends Controller /** * Show the form for editing the specified Pirep. - * @param int $id - * @return Response + * + * @param int $id + * * @throws \InvalidArgumentException + * + * @return Response */ public function edit($id) { @@ -296,13 +314,13 @@ class PirepController extends Controller $pirep->hours = $time->hours; $pirep->minutes = $time->minutes; - # set the custom fields + // set the custom fields foreach ($pirep->fields as $field) { $field_name = 'field_'.$field->slug; $pirep->{$field_name} = $field->value; } - # set the fares + // set the fares foreach ($pirep->fares as $fare) { $field_name = 'fare_'.$fare->fare_id; $pirep->{$field_name} = $fare->count; @@ -323,9 +341,11 @@ class PirepController extends Controller /** * @param $id * @param UpdatePirepRequest $request - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * * @throws \Prettus\Validator\Exceptions\ValidatorException * @throws \Exception + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update($id, UpdatePirepRequest $request) { @@ -341,7 +361,7 @@ class PirepController extends Controller $attrs = $request->all(); - # Fix the time + // Fix the time $attrs['flight_time'] = Time::init( $attrs['minutes'], $attrs['hours'])->getMinutes(); @@ -362,7 +382,9 @@ class PirepController extends Controller /** * Remove the specified Pirep from storage. - * @param int $id + * + * @param int $id + * * @return Response */ public function destroy($id) @@ -382,7 +404,9 @@ class PirepController extends Controller /** * Change or update the PIREP status. Just return the new actionbar + * * @param Request $request + * * @return \Illuminate\View\View */ public function status(Request $request) @@ -402,10 +426,13 @@ class PirepController extends Controller /** * Add a comment to the Pirep + * * @param $id * @param Request $request - * @return mixed + * * @throws \Exception + * + * @return mixed */ public function comments($id, Request $request) { diff --git a/app/Http/Controllers/Admin/PirepFieldController.php b/app/Http/Controllers/Admin/PirepFieldController.php index be1cc7ee..7325b6e5 100644 --- a/app/Http/Controllers/Admin/PirepFieldController.php +++ b/app/Http/Controllers/Admin/PirepFieldController.php @@ -13,7 +13,6 @@ use Response; /** * Class PirepFieldController - * @package App\Http\Controllers\Admin */ class PirepFieldController extends Controller { @@ -21,6 +20,7 @@ class PirepFieldController extends Controller /** * PirepFieldController constructor. + * * @param PirepFieldRepository $pirepFieldRepo */ public function __construct( @@ -31,9 +31,12 @@ class PirepFieldController extends Controller /** * Display a listing of the PirepField. + * * @param Request $request - * @return Response + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return Response */ public function index(Request $request) { @@ -47,6 +50,7 @@ class PirepFieldController extends Controller /** * Show the form for creating a new PirepField. + * * @return Response */ public function create() @@ -56,9 +60,12 @@ class PirepFieldController extends Controller /** * Store a newly created PirepField in storage. + * * @param CreatePirepFieldRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function store(CreatePirepFieldRequest $request) { @@ -75,7 +82,9 @@ class PirepFieldController extends Controller /** * Display the specified PirepField. - * @param int $id + * + * @param int $id + * * @return Response */ public function show($id) @@ -95,7 +104,9 @@ class PirepFieldController extends Controller /** * Show the form for editing the specified PirepField. - * @param int $id + * + * @param int $id + * * @return Response */ public function edit($id) @@ -115,6 +126,9 @@ class PirepFieldController extends Controller /** * Update the specified PirepField in storage. + * + * @param mixed $id + * * @throws \Prettus\Validator\Exceptions\ValidatorException */ public function update($id, UpdatePirepFieldRequest $request) @@ -139,7 +153,9 @@ class PirepFieldController extends Controller /** * Remove the specified PirepField from storage. - * @param int $id + * + * @param int $id + * * @return Response */ public function destroy($id) diff --git a/app/Http/Controllers/Admin/RankController.php b/app/Http/Controllers/Admin/RankController.php index 9fa313cd..8aed2b35 100644 --- a/app/Http/Controllers/Admin/RankController.php +++ b/app/Http/Controllers/Admin/RankController.php @@ -16,16 +16,16 @@ use Response; /** * Class RankController - * @package App\Http\Controllers\Admin */ class RankController extends Controller { - private $fleetSvc, - $rankRepository, - $subfleetRepo; + private $fleetSvc; + private $rankRepository; + private $subfleetRepo; /** * RankController constructor. + * * @param FleetService $fleetSvc * @param RankRepository $rankingRepo * @param SubfleetRepository $subfleetRepo @@ -42,7 +42,9 @@ class RankController extends Controller /** * Get the available subfleets for a rank + * * @param $rank + * * @return array */ protected function getAvailSubfleets($rank) @@ -60,9 +62,12 @@ class RankController extends Controller /** * Display a listing of the Ranking. + * * @param Request $request - * @return Response + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return Response */ public function index(Request $request) { @@ -86,9 +91,12 @@ class RankController extends Controller /** * Store a newly created Ranking in storage. + * * @param CreateRankRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function store(CreateRankRequest $request) { @@ -104,7 +112,9 @@ class RankController extends Controller /** * Display the specified Ranking. - * @param int $id + * + * @param int $id + * * @return Response */ public function show($id) @@ -118,13 +128,15 @@ class RankController extends Controller } return view('admin.ranks.show', [ - 'rank' => $rank + 'rank' => $rank, ]); } /** * Show the form for editing the specified Ranking. - * @param int $id + * + * @param int $id + * * @return Response */ public function edit($id) @@ -147,10 +159,13 @@ class RankController extends Controller /** * Update the specified Ranking in storage. - * @param int $id + * + * @param int $id * @param UpdateRankRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function update($id, UpdateRankRequest $request) { @@ -172,7 +187,9 @@ class RankController extends Controller /** * Remove the specified Ranking from storage. - * @param int $id + * + * @param int $id + * * @return Response */ public function destroy($id) @@ -194,6 +211,7 @@ class RankController extends Controller /** * @param $rank + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ protected function return_subfleet_view($rank) @@ -208,8 +226,10 @@ class RankController extends Controller /** * Subfleet operations on a rank + * * @param $id * @param Request $request + * * @return mixed */ public function subfleets($id, Request $request) diff --git a/app/Http/Controllers/Admin/SettingsController.php b/app/Http/Controllers/Admin/SettingsController.php index be20ec32..3a560598 100644 --- a/app/Http/Controllers/Admin/SettingsController.php +++ b/app/Http/Controllers/Admin/SettingsController.php @@ -9,7 +9,6 @@ use Log; /** * Class SettingsController - * @package App\Http\Controllers\Admin */ class SettingsController extends Controller { @@ -28,7 +27,9 @@ class SettingsController extends Controller /** * Update the specified setting in storage. + * * @param Request $request + * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update(Request $request) diff --git a/app/Http/Controllers/Admin/SubfleetController.php b/app/Http/Controllers/Admin/SubfleetController.php index de821046..c0702b36 100644 --- a/app/Http/Controllers/Admin/SubfleetController.php +++ b/app/Http/Controllers/Admin/SubfleetController.php @@ -27,20 +27,20 @@ use Storage; /** * Class SubfleetController - * @package App\Http\Controllers\Admin */ class SubfleetController extends Controller { - private $aircraftRepo, - $fareRepo, - $fareSvc, - $fleetSvc, - $importSvc, - $rankRepo, - $subfleetRepo; + private $aircraftRepo; + private $fareRepo; + private $fareSvc; + private $fleetSvc; + private $importSvc; + private $rankRepo; + private $subfleetRepo; /** * SubfleetController constructor. + * * @param AircraftRepository $aircraftRepo * @param FleetService $fleetSvc * @param FareRepository $fareRepo @@ -69,7 +69,9 @@ class SubfleetController extends Controller /** * Get the ranks that are available to the subfleet + * * @param $subfleet + * * @return array */ protected function getAvailRanks($subfleet) @@ -86,6 +88,8 @@ class SubfleetController extends Controller /** * Get all the fares that haven't been assigned to a given subfleet + * + * @param mixed $subfleet */ protected function getAvailFares($subfleet) { @@ -104,9 +108,12 @@ class SubfleetController extends Controller /** * Display a listing of the Subfleet. + * * @param Request $request - * @return Response + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return Response */ public function index(Request $request) { @@ -120,6 +127,7 @@ class SubfleetController extends Controller /** * Show the form for creating a new Subfleet. + * * @return Response */ public function create() @@ -132,9 +140,12 @@ class SubfleetController extends Controller /** * Store a newly created Subfleet in storage. + * * @param CreateSubfleetRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function store(CreateSubfleetRequest $request) { @@ -147,7 +158,9 @@ class SubfleetController extends Controller /** * Display the specified Subfleet. - * @param int $id + * + * @param int $id + * * @return Response */ public function show($id) @@ -168,7 +181,9 @@ class SubfleetController extends Controller /** * Show the form for editing the specified Subfleet. - * @param int $id + * + * @param int $id + * * @return Response */ public function edit($id) @@ -194,10 +209,13 @@ class SubfleetController extends Controller /** * Update the specified Subfleet in storage. - * @param int $id + * + * @param int $id * @param UpdateSubfleetRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function update($id, UpdateSubfleetRequest $request) { @@ -216,7 +234,9 @@ class SubfleetController extends Controller /** * Remove the specified Subfleet from storage. - * @param int $id + * + * @param int $id + * * @return Response */ public function destroy($id) @@ -228,8 +248,8 @@ class SubfleetController extends Controller return redirect(route('admin.subfleets.index')); } - # Make sure no aircraft are assigned to this subfleet - # before trying to delete it, or else things might go boom + // Make sure no aircraft are assigned to this subfleet + // before trying to delete it, or else things might go boom $aircraft = $this->aircraftRepo->findWhere(['subfleet_id' => $id], ['id']); if ($aircraft->count() > 0) { Flash::error('There are aircraft still assigned to this subfleet, you can\'t delete it!')->important(); @@ -244,7 +264,9 @@ class SubfleetController extends Controller /** * Run the subfleet exporter + * * @param Request $request + * * @return \Symfony\Component\HttpFoundation\BinaryFileResponse */ public function export(Request $request) @@ -261,10 +283,11 @@ class SubfleetController extends Controller } /** - * * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Illuminate\Validation\ValidationException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function import(Request $request) { @@ -292,6 +315,7 @@ class SubfleetController extends Controller /** * @param Subfleet $subfleet + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ protected function return_ranks_view(?Subfleet $subfleet) @@ -307,6 +331,7 @@ class SubfleetController extends Controller /** * @param Subfleet $subfleet + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ protected function return_fares_view(?Subfleet $subfleet) @@ -322,8 +347,10 @@ class SubfleetController extends Controller /** * Operations for associating ranks to the subfleet + * * @param $id * @param Request $request + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function ranks($id, Request $request) @@ -337,7 +364,7 @@ class SubfleetController extends Controller return $this->return_ranks_view($subfleet); } - /** + /* * update specific rank data */ if ($request->isMethod('post')) { @@ -362,6 +389,7 @@ class SubfleetController extends Controller /** * @param Subfleet $subfleet + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ protected function return_expenses_view(?Subfleet $subfleet) @@ -374,10 +402,13 @@ class SubfleetController extends Controller /** * Operations for associating ranks to the subfleet + * * @param $id * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Exception + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function expenses($id, Request $request) { @@ -390,7 +421,7 @@ class SubfleetController extends Controller return $this->return_expenses_view($subfleet); } - /** + /* * update specific rank data */ if ($request->isMethod('post')) { @@ -413,8 +444,10 @@ class SubfleetController extends Controller /** * Operations on fares to the subfleet + * * @param $id * @param Request $request + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function fares($id, Request $request) @@ -428,7 +461,7 @@ class SubfleetController extends Controller return $this->return_fares_view($subfleet); } - /** + /* * update specific fare data */ if ($request->isMethod('post')) { diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 9ad1607b..5419460b 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -25,18 +25,18 @@ use Response; /** * Class UserController - * @package App\Http\Controllers\Admin */ class UserController extends Controller { - private $airlineRepo, - $airportRepo, - $pirepRepo, - $userRepo, - $userSvc; + private $airlineRepo; + private $airportRepo; + private $pirepRepo; + private $userRepo; + private $userSvc; /** * UserController constructor. + * * @param AirlineRepository $airlineRepo * @param AirportRepository $airportRepo * @param PirepRepository $pirepRepo @@ -59,6 +59,7 @@ class UserController extends Controller /** * @param Request $request + * * @return mixed */ public function index(Request $request) @@ -78,6 +79,7 @@ class UserController extends Controller /** * Show the form for creating a new User. + * * @return Response */ public function create() @@ -99,9 +101,12 @@ class UserController extends Controller /** * Store a newly created User in storage. + * * @param CreateUserRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function store(CreateUserRequest $request) { @@ -114,7 +119,9 @@ class UserController extends Controller /** * Display the specified User. - * @param int $id + * + * @param int $id + * * @return Response */ public function show($id) @@ -148,7 +155,9 @@ class UserController extends Controller /** * Show the form for editing the specified User. - * @param int $id + * + * @param int $id + * * @return Response */ public function edit($id) @@ -165,7 +174,7 @@ class UserController extends Controller ->whereOrder(['user_id' => $id], 'created_at', 'desc') ->paginate(); - $countries = collect((new \League\ISO3166\ISO3166)->all()) + $countries = collect((new \League\ISO3166\ISO3166())->all()) ->mapWithKeys(function ($item, $key) { return [strtolower($item['alpha2']) => $item['name']]; }); @@ -187,10 +196,13 @@ class UserController extends Controller /** * Update the specified User in storage. + * * @param int $id * @param UpdateUserRequest $request - * @return Response + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return Response */ public function update($id, UpdateUserRequest $request) { @@ -211,7 +223,7 @@ class UserController extends Controller if ($request->filled('avatar_upload')) { /** - * @var $file \Illuminate\Http\UploadedFile + * @var $file \Illuminate\Http\UploadedFile */ $file = $request->file('avatar_upload'); $file_path = $file->storeAs( @@ -223,7 +235,6 @@ class UserController extends Controller $user->avatar = $file_path; } - $original_user_state = $user->state; $user = $this->userRepo->update($req_data, $id); @@ -232,7 +243,7 @@ class UserController extends Controller $this->userSvc->changeUserState($user, $original_user_state); } - # Delete all of the roles and then re-attach the valid ones + // Delete all of the roles and then re-attach the valid ones DB::table('role_user')->where('user_id', $id)->delete(); foreach ($request->input('roles') as $key => $value) { $user->attachRole($value); @@ -245,7 +256,9 @@ class UserController extends Controller /** * Remove the specified User from storage. - * @param int $id + * + * @param int $id + * * @return Response */ public function destroy($id) @@ -267,8 +280,10 @@ class UserController extends Controller /** * Regenerate the user's API key + * * @param $id * @param Request $request + * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function regen_apikey($id, Request $request) diff --git a/app/Http/Controllers/Api/AcarsController.php b/app/Http/Controllers/Api/AcarsController.php index 5a30c24e..4d42ec80 100644 --- a/app/Http/Controllers/Api/AcarsController.php +++ b/app/Http/Controllers/Api/AcarsController.php @@ -23,17 +23,17 @@ use Log; /** * Class AcarsController - * @package App\Http\Controllers\Api */ class AcarsController extends Controller { - private $acarsRepo, - $geoSvc, - $pirepRepo, - $pirepSvc; + private $acarsRepo; + private $geoSvc; + private $pirepRepo; + private $pirepSvc; /** * AcarsController constructor. + * * @param AcarsRepository $acarsRepo * @param GeoService $geoSvc * @param PirepRepository $pirepRepo @@ -53,7 +53,9 @@ class AcarsController extends Controller /** * Check if a PIREP is cancelled + * * @param $pirep + * * @throws \App\Exceptions\PirepCancelled */ protected function checkCancelled(Pirep $pirep) @@ -65,7 +67,9 @@ class AcarsController extends Controller /** * Return all of the flights (as points) in GeoJSON format + * * @param Request $request + * * @return mixed */ public function index(Request $request) @@ -74,14 +78,16 @@ class AcarsController extends Controller $positions = $this->geoSvc->getFeatureForLiveFlights($pireps); return response(json_encode($positions), 200, [ - 'Content-type' => 'application/json' + 'Content-type' => 'application/json', ]); } /** * Return the GeoJSON for the ACARS line + * * @param $pirep_id * @param Request $request + * * @return \Illuminate\Contracts\Routing\ResponseFactory */ public function acars_geojson($pirep_id, Request $request) @@ -96,8 +102,10 @@ class AcarsController extends Controller /** * Return the routes for the ACARS line + * * @param $id * @param Request $request + * * @return AcarsRouteResource */ public function acars_get($id, Request $request) @@ -106,21 +114,24 @@ class AcarsController extends Controller return new AcarsRouteResource(Acars::where([ 'pirep_id' => $id, - 'type' => AcarsType::FLIGHT_PATH + 'type' => AcarsType::FLIGHT_PATH, ])->orderBy('sim_time', 'asc')->get()); } /** * Post ACARS updates for a PIREP + * * @param $id * @param PositionRequest $request - * @return \Illuminate\Http\JsonResponse + * * @throws \App\Exceptions\PirepCancelled * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException + * + * @return \Illuminate\Http\JsonResponse */ public function acars_store($id, PositionRequest $request) { - # Check if the status is cancelled... + // Check if the status is cancelled... $pirep = Pirep::find($id); $this->checkCancelled($pirep); @@ -146,10 +157,10 @@ class AcarsController extends Controller $update = Acars::create($position); $update->save(); - ++$count; + $count++; } - # Change the PIREP status if it's as SCHEDULED before + // Change the PIREP status if it's as SCHEDULED before if ($pirep->status === PirepStatus::INITIATED) { $pirep->status = PirepStatus::AIRBORNE; } @@ -162,15 +173,18 @@ class AcarsController extends Controller /** * Post ACARS LOG update for a PIREP. These updates won't show up on the map * But rather in a log file. + * * @param $id * @param LogRequest $request - * @return \Illuminate\Http\JsonResponse + * * @throws \App\Exceptions\PirepCancelled * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException + * + * @return \Illuminate\Http\JsonResponse */ public function acars_logs($id, LogRequest $request) { - # Check if the status is cancelled... + // Check if the status is cancelled... $pirep = Pirep::find($id); $this->checkCancelled($pirep); @@ -192,7 +206,7 @@ class AcarsController extends Controller $acars = Acars::create($log); $acars->save(); - ++$count; + $count++; } return $this->message($count.' logs added', $count); @@ -201,15 +215,18 @@ class AcarsController extends Controller /** * Post ACARS LOG update for a PIREP. These updates won't show up on the map * But rather in a log file. + * * @param $id * @param EventRequest $request - * @return \Illuminate\Http\JsonResponse + * * @throws \App\Exceptions\PirepCancelled * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException + * + * @return \Illuminate\Http\JsonResponse */ public function acars_events($id, EventRequest $request) { - # Check if the status is cancelled... + // Check if the status is cancelled... $pirep = Pirep::find($id); $this->checkCancelled($pirep); @@ -232,7 +249,7 @@ class AcarsController extends Controller $acars = Acars::create($log); $acars->save(); - ++$count; + $count++; } return $this->message($count.' logs added', $count); diff --git a/app/Http/Controllers/Api/AirlineController.php b/app/Http/Controllers/Api/AirlineController.php index 73a7a618..293aba68 100644 --- a/app/Http/Controllers/Api/AirlineController.php +++ b/app/Http/Controllers/Api/AirlineController.php @@ -9,7 +9,6 @@ use Illuminate\Http\Request; /** * Class AirlineController - * @package App\Http\Controllers\Api */ class AirlineController extends Controller { @@ -17,6 +16,7 @@ class AirlineController extends Controller /** * AirlineController constructor. + * * @param AirlineRepository $airlineRepo */ public function __construct( @@ -27,12 +27,14 @@ class AirlineController extends Controller /** * Return all the airlines, paginated + * * @param Request $request + * * @return mixed */ public function index(Request $request) { - #$this->airlineRepo->pushCriteria(new RequestCriteria($request)); + //$this->airlineRepo->pushCriteria(new RequestCriteria($request)); $airports = $this->airlineRepo ->whereOrder(['active' => true], 'name', 'asc') ->paginate(); @@ -42,7 +44,9 @@ class AirlineController extends Controller /** * Do a lookup, via vaCentral, for the airport information + * * @param $id + * * @return AirlineResource */ public function get($id) diff --git a/app/Http/Controllers/Api/AirportController.php b/app/Http/Controllers/Api/AirportController.php index 1ea3c499..b450ea32 100644 --- a/app/Http/Controllers/Api/AirportController.php +++ b/app/Http/Controllers/Api/AirportController.php @@ -12,7 +12,6 @@ use VaCentral\Airport as AirportLookup; /** * Class AirportController - * @package App\Http\Controllers\Api */ class AirportController extends Controller { @@ -20,6 +19,7 @@ class AirportController extends Controller /** * AirportController constructor. + * * @param AirportRepository $airportRepo */ public function __construct( @@ -30,7 +30,9 @@ class AirportController extends Controller /** * Return all the airports, paginated + * * @param Request $request + * * @return mixed */ public function index(Request $request) @@ -65,7 +67,9 @@ class AirportController extends Controller /** * Do a lookup, via vaCentral, for the airport information + * * @param $id + * * @return AirportResource */ public function get($id) @@ -77,7 +81,9 @@ class AirportController extends Controller /** * Do a lookup, via vaCentral, for the airport information + * * @param $id + * * @return AirportResource */ public function lookup($id) diff --git a/app/Http/Controllers/Api/FleetController.php b/app/Http/Controllers/Api/FleetController.php index b93d4c2a..81d7c731 100644 --- a/app/Http/Controllers/Api/FleetController.php +++ b/app/Http/Controllers/Api/FleetController.php @@ -11,15 +11,15 @@ use Illuminate\Http\Request; /** * Class FleetController - * @package App\Http\Controllers\Api */ class FleetController extends Controller { - private $aircraftRepo, - $subfleetRepo; + private $aircraftRepo; + private $subfleetRepo; /** * FleetController constructor. + * * @param AircraftRepository $aircraftRepo * @param SubfleetRepository $subfleetRepo */ @@ -47,8 +47,10 @@ class FleetController extends Controller /** * Get a specific aircraft. Query string required to specify the tail * /api/aircraft/XYZ?type=registration + * * @param $id * @param Request $request + * * @return AircraftResource */ public function get_aircraft($id, Request $request) diff --git a/app/Http/Controllers/Api/FlightController.php b/app/Http/Controllers/Api/FlightController.php index 4d156200..a27613cf 100644 --- a/app/Http/Controllers/Api/FlightController.php +++ b/app/Http/Controllers/Api/FlightController.php @@ -15,15 +15,15 @@ use Prettus\Repository\Exceptions\RepositoryException; /** * Class FlightController - * @package App\Http\Controllers\Api */ class FlightController extends Controller { - private $flightRepo, - $flightSvc; + private $flightRepo; + private $flightSvc; /** * FlightController constructor. + * * @param FlightRepository $flightRepo * @param FlightService $flightSvc */ @@ -37,7 +37,9 @@ class FlightController extends Controller /** * Return all the flights, paginated + * * @param Request $request + * * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection */ public function index(Request $request) @@ -49,7 +51,7 @@ class FlightController extends Controller 'visible' => true, ]; - if(setting('pilots.restrict_to_company')) { + if (setting('pilots.restrict_to_company')) { $where['airline_id'] = Auth::user()->airline_id; } if (setting('pilots.only_flights_from_current', false)) { @@ -69,6 +71,7 @@ class FlightController extends Controller /** * @param $id + * * @return FlightResource */ public function get($id) @@ -81,6 +84,7 @@ class FlightController extends Controller /** * @param Request $request + * * @return mixed */ public function search(Request $request) @@ -93,7 +97,7 @@ class FlightController extends Controller 'visible' => true, ]; - if(setting('pilots.restrict_to_company')) { + if (setting('pilots.restrict_to_company')) { $where['airline_id'] = Auth::user()->airline_id; } if (setting('pilots.only_flights_from_current')) { @@ -117,8 +121,10 @@ class FlightController extends Controller /** * Get a flight's route + * * @param $id * @param Request $request + * * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection */ public function route($id, Request $request) diff --git a/app/Http/Controllers/Api/NewsController.php b/app/Http/Controllers/Api/NewsController.php index 0b8e1c4d..8abe9574 100644 --- a/app/Http/Controllers/Api/NewsController.php +++ b/app/Http/Controllers/Api/NewsController.php @@ -7,24 +7,25 @@ use App\Interfaces\Controller; use App\Repositories\NewsRepository; use Illuminate\Http\Request; -/** - * @package App\Http\Controllers\Api - */ class NewsController extends Controller { private $newsRepo; /** * AirlineController constructor. + * * @param NewsRepository $newsRepo */ - public function __construct(NewsRepository $newsRepo) { + public function __construct(NewsRepository $newsRepo) + { $this->newsRepo = $newsRepo; } /** * Return all the airlines, paginated + * * @param Request $request + * * @return mixed */ public function index(Request $request) diff --git a/app/Http/Controllers/Api/PirepController.php b/app/Http/Controllers/Api/PirepController.php index 77f53c67..d47e7911 100644 --- a/app/Http/Controllers/Api/PirepController.php +++ b/app/Http/Controllers/Api/PirepController.php @@ -40,20 +40,20 @@ use Log; /** * Class PirepController - * @package App\Http\Controllers\Api */ class PirepController extends Controller { - private $acarsRepo, - $fareSvc, - $financeSvc, - $journalRepo, - $pirepRepo, - $pirepSvc, - $userSvc; + private $acarsRepo; + private $fareSvc; + private $financeSvc; + private $journalRepo; + private $pirepRepo; + private $pirepSvc; + private $userSvc; /** * PirepController constructor. + * * @param AcarsRepository $acarsRepo * @param FareService $fareSvc * @param PirepFinanceService $financeSvc @@ -82,7 +82,9 @@ class PirepController extends Controller /** * Parse any PIREP added in + * * @param Request $request + * * @return array|null|string */ protected function parsePirep(Request $request) @@ -98,7 +100,9 @@ class PirepController extends Controller /** * Check if a PIREP is cancelled + * * @param $pirep + * * @throws \App\Exceptions\PirepCancelled */ protected function checkCancelled(Pirep $pirep) @@ -132,8 +136,10 @@ class PirepController extends Controller /** * Save the fares + * * @param $pirep * @param Request $request + * * @throws \Exception */ protected function updateFares($pirep, Request $request) @@ -155,14 +161,15 @@ class PirepController extends Controller /** * Get all the active PIREPs + * * @return mixed */ public function index() { $active = []; $pireps = $this->acarsRepo->getPositions(); - foreach($pireps as $pirep) { - if(!$pirep->position) { + foreach ($pireps as $pirep) { + if (!$pirep->position) { continue; } @@ -174,6 +181,7 @@ class PirepController extends Controller /** * @param $pirep_id + * * @return PirepResource */ public function get($pirep_id) @@ -187,12 +195,14 @@ class PirepController extends Controller * status, and whatever other statuses may be defined * * @param PrefileRequest $request - * @return PirepResource + * * @throws \App\Exceptions\AircraftNotAtAirport * @throws \App\Exceptions\UserNotAtAirport * @throws \App\Exceptions\PirepCancelled * @throws \App\Exceptions\AircraftPermissionDenied * @throws \Exception + * + * @return PirepResource */ public function prefile(PrefileRequest $request) { @@ -211,28 +221,25 @@ class PirepController extends Controller $pirep = new Pirep($attrs); - # See if this user is at the current airport + // See if this user is at the current airport if (setting('pilots.only_flights_from_current') - && $user->curr_airport_id !== $pirep->dpt_airport_id) - { + && $user->curr_airport_id !== $pirep->dpt_airport_id) { throw new UserNotAtAirport(); } - # See if this user is allowed to fly this aircraft + // See if this user is allowed to fly this aircraft if (setting('pireps.restrict_aircraft_to_rank', false) - && !$this->userSvc->aircraftAllowed($user, $pirep->aircraft_id)) - { + && !$this->userSvc->aircraftAllowed($user, $pirep->aircraft_id)) { throw new AircraftPermissionDenied(); } - # See if this aircraft is at the departure airport + // See if this aircraft is at the departure airport if (setting('pireps.only_aircraft_at_dpt_airport') - && $pirep->aircraft_id !== $pirep->dpt_airport_id) - { + && $pirep->aircraft_id !== $pirep->dpt_airport_id) { throw new AircraftNotAtAirport(); } - # Find if there's a duplicate, if so, let's work on that + // Find if there's a duplicate, if so, let's work on that $dupe_pirep = $this->pirepSvc->findDuplicate($pirep); if ($dupe_pirep !== false) { $pirep = $dupe_pirep; @@ -240,7 +247,7 @@ class PirepController extends Controller } // Default to a scheduled passenger flight - if(!array_key_exists('flight_type', $attrs)) { + if (!array_key_exists('flight_type', $attrs)) { $attrs['flight_type'] = 'J'; } @@ -262,11 +269,13 @@ class PirepController extends Controller * * @param $pirep_id * @param UpdateRequest $request - * @return PirepResource + * * @throws \App\Exceptions\PirepCancelled * @throws \App\Exceptions\AircraftPermissionDenied * @throws \Prettus\Validator\Exceptions\ValidatorException * @throws \Exception + * + * @return PirepResource */ public function update($pirep_id, UpdateRequest $request) { @@ -280,7 +289,7 @@ class PirepController extends Controller $attrs = $this->parsePirep($request); $attrs['user_id'] = Auth::id(); - # If aircraft is being changed, see if this user is allowed to fly this aircraft + // If aircraft is being changed, see if this user is allowed to fly this aircraft if (array_key_exists('aircraft_id', $attrs) && setting('pireps.restrict_aircraft_to_rank', false) ) { @@ -299,13 +308,16 @@ class PirepController extends Controller /** * File the PIREP + * * @param $pirep_id * @param FileRequest $request - * @return PirepResource + * * @throws \App\Exceptions\PirepCancelled * @throws \App\Exceptions\AircraftPermissionDenied * @throws \Illuminate\Database\Eloquent\ModelNotFoundException * @throws \Exception + * + * @return PirepResource */ public function file($pirep_id, FileRequest $request) { @@ -313,13 +325,13 @@ class PirepController extends Controller $user = Auth::user(); - # Check if the status is cancelled... + // Check if the status is cancelled... $pirep = Pirep::find($pirep_id); $this->checkCancelled($pirep); $attrs = $this->parsePirep($request); - # If aircraft is being changed, see if this user is allowed to fly this aircraft + // If aircraft is being changed, see if this user is allowed to fly this aircraft if (array_key_exists('aircraft_id', $attrs) && setting('pireps.restrict_aircraft_to_rank', false) ) { @@ -343,9 +355,9 @@ class PirepController extends Controller Log::error($e); } - # See if there there is any route data posted - # If there isn't, then just write the route data from the - # route that's been posted from the PIREP + // See if there there is any route data posted + // If there isn't, then just write the route data from the + // route that's been posted from the PIREP $w = ['pirep_id' => $pirep->id, 'type' => AcarsType::ROUTE]; $count = Acars::where($w)->count(['id']); if ($count === 0) { @@ -357,10 +369,13 @@ class PirepController extends Controller /** * Cancel the PIREP + * * @param $pirep_id * @param Request $request - * @return PirepResource + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return PirepResource */ public function cancel($pirep_id, Request $request) { @@ -376,7 +391,9 @@ class PirepController extends Controller /** * Add a new comment - * @param $id + * + * @param $id + * * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection */ public function comments_get($id) @@ -387,10 +404,13 @@ class PirepController extends Controller /** * Add a new comment + * * @param $id * @param CommentRequest $request - * @return PirepCommentResource + * * @throws \App\Exceptions\PirepCancelled + * + * @return PirepCommentResource */ public function comments_post($id, CommentRequest $request) { @@ -399,7 +419,7 @@ class PirepController extends Controller Log::debug('Posting comment, PIREP: '.$id, $request->post()); - # Add it + // Add it $comment = new PirepComment($request->post()); $comment->pirep_id = $id; $comment->user_id = Auth::id(); @@ -410,7 +430,9 @@ class PirepController extends Controller /** * Get all of the fields for a PIREP + * * @param $pirep_id + * * @return PirepFieldCollection */ public function fields_get($pirep_id) @@ -421,8 +443,10 @@ class PirepController extends Controller /** * Set any fields for a PIREP + * * @param string $pirep_id * @param FieldsRequest $request + * * @return PirepFieldCollection */ public function fields_post($pirep_id, FieldsRequest $request) @@ -436,10 +460,12 @@ class PirepController extends Controller } /** - * @param $id - * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection + * @param $id + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException + * + * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection */ public function finances_get($id) { @@ -451,11 +477,13 @@ class PirepController extends Controller /** * @param $id * @param Request $request - * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException * @throws \Exception * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection */ public function finances_recalculate($id, Request $request) { @@ -471,6 +499,7 @@ class PirepController extends Controller /** * @param $id * @param Request $request + * * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection */ public function route_get($id, Request $request) @@ -478,22 +507,25 @@ class PirepController extends Controller $pirep = Pirep::find($id); return AcarsRouteResource::collection(Acars::where([ 'pirep_id' => $id, - 'type' => AcarsType::ROUTE + 'type' => AcarsType::ROUTE, ])->orderBy('order', 'asc')->get()); } /** * Post the ROUTE for a PIREP, can be done from the ACARS log + * * @param $id * @param RouteRequest $request - * @return \Illuminate\Http\JsonResponse + * * @throws \App\Exceptions\PirepCancelled * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException * @throws \Exception + * + * @return \Illuminate\Http\JsonResponse */ public function route_post($id, RouteRequest $request) { - # Check if the status is cancelled... + // Check if the status is cancelled... $pirep = Pirep::find($id); $this->checkCancelled($pirep); @@ -502,7 +534,7 @@ class PirepController extends Controller // Delete the route before posting a new one Acars::where([ 'pirep_id' => $id, - 'type' => AcarsType::ROUTE + 'type' => AcarsType::ROUTE, ])->delete(); $count = 0; @@ -518,7 +550,7 @@ class PirepController extends Controller $acars = Acars::create($position); $acars->save(); - ++$count; + $count++; } return $this->message($count.' points added', $count); @@ -527,8 +559,10 @@ class PirepController extends Controller /** * @param $id * @param Request $request - * @return \Illuminate\Http\JsonResponse + * * @throws \Exception + * + * @return \Illuminate\Http\JsonResponse */ public function route_delete($id, Request $request) { @@ -536,7 +570,7 @@ class PirepController extends Controller Acars::where([ 'pirep_id' => $id, - 'type' => AcarsType::ROUTE + 'type' => AcarsType::ROUTE, ])->delete(); return $this->message('Route deleted'); diff --git a/app/Http/Controllers/Api/SettingsController.php b/app/Http/Controllers/Api/SettingsController.php index 3e32caca..a4c66205 100644 --- a/app/Http/Controllers/Api/SettingsController.php +++ b/app/Http/Controllers/Api/SettingsController.php @@ -9,7 +9,6 @@ use Illuminate\Http\Request; /** * Class SettingsController - * @package App\Http\Controllers\Api */ class SettingsController extends Controller { @@ -17,6 +16,7 @@ class SettingsController extends Controller /** * SettingsController constructor. + * * @param SettingRepository $settingRepo */ public function __construct( @@ -27,7 +27,9 @@ class SettingsController extends Controller /** * Return all the airlines, paginated + * * @param Request $request + * * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection */ public function index(Request $request) diff --git a/app/Http/Controllers/Api/StatusController.php b/app/Http/Controllers/Api/StatusController.php index a79ed9d0..c8202ae3 100644 --- a/app/Http/Controllers/Api/StatusController.php +++ b/app/Http/Controllers/Api/StatusController.php @@ -7,7 +7,6 @@ use PragmaRX\Version\Package\Facade as Version; /** * Class StatusController - * @package App\Http\Controllers\Api */ class StatusController extends Controller { diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 5ba6bd2a..b86392a6 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -2,7 +2,6 @@ namespace App\Http\Controllers\Api; -use App\Exceptions\BidExists; use App\Http\Resources\Bid as BidResource; use App\Http\Resources\Pirep as PirepResource; use App\Http\Resources\Subfleet as SubfleetResource; @@ -24,19 +23,19 @@ use Prettus\Repository\Exceptions\RepositoryException; /** * Class UserController - * @package App\Http\Controllers\Api */ class UserController extends Controller { - private $flightRepo, - $flightSvc, - $pirepRepo, - $subfleetRepo, - $userRepo, - $userSvc; + private $flightRepo; + private $flightSvc; + private $pirepRepo; + private $subfleetRepo; + private $userRepo; + private $userSvc; /** * UserController constructor. + * * @param FlightRepository $flightRepo * @param FlightService $flightSvc * @param PirepRepository $pirepRepo @@ -62,6 +61,7 @@ class UserController extends Controller /** * @param Request $request + * * @return int|mixed */ protected function getUserId(Request $request) @@ -75,7 +75,9 @@ class UserController extends Controller /** * Return the profile for the currently auth'd user + * * @param Request $request + * * @return UserResource */ public function index(Request $request) @@ -85,7 +87,9 @@ class UserController extends Controller /** * Get the profile for the passed-in user + * * @param $id + * * @return UserResource */ public function get($id) @@ -95,16 +99,19 @@ class UserController extends Controller /** * Return all of the bids for the passed-in user + * * @param Request $request - * @return mixed + * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException * @throws \App\Exceptions\BidExists + * + * @return mixed */ public function bids(Request $request) { $user = $this->userRepo->find($this->getUserId($request)); - # Add a bid + // Add a bid if ($request->isMethod('PUT') || $request->isMethod('POST')) { $flight_id = $request->input('flight_id'); $flight = $this->flightRepo->find($flight_id); @@ -125,7 +132,7 @@ class UserController extends Controller $this->flightSvc->removeBid($flight, $user); } - # Return the flights they currently have bids on + // Return the flights they currently have bids on $bids = Bid::where(['user_id' => $user->id])->get(); return BidResource::collection($bids); @@ -133,7 +140,9 @@ class UserController extends Controller /** * Return the fleet that this user is allowed to + * * @param Request $request + * * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection */ public function fleet(Request $request) @@ -146,8 +155,10 @@ class UserController extends Controller /** * @param Request $request - * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection + * * @throws RepositoryException + * + * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection */ public function pireps(Request $request) { diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 01391717..c3f9b98c 100755 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -7,7 +7,6 @@ use Illuminate\Foundation\Auth\SendsPasswordResetEmails; /** * Class ForgotPasswordController - * @package App\Http\Controllers\Auth */ class ForgotPasswordController extends Controller { diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 668bd419..f714c8bf 100755 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -11,7 +11,6 @@ use Illuminate\Support\Facades\Log; /** * Class LoginController - * @package App\Http\Controllers\Auth */ class LoginController extends Controller { @@ -38,6 +37,7 @@ class LoginController extends Controller /** * @param Request $request + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View */ protected function sendLoginResponse(Request $request) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 28bc0737..9658b14b 100755 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -19,7 +19,6 @@ use Validator; /** * Class RegisterController - * @package App\Http\Controllers\Auth */ class RegisterController extends Controller { @@ -27,16 +26,18 @@ class RegisterController extends Controller /** * Where to redirect users after login / registration. + * * @var string */ protected $redirectTo = '/'; - private $airlineRepo, - $airportRepo, - $userService; + private $airlineRepo; + private $airportRepo; + private $userService; /** * RegisterController constructor. + * * @param AirlineRepository $airlineRepo * @param AirportRepository $airportRepo * @param UserService $userService @@ -72,7 +73,9 @@ class RegisterController extends Controller /** * Get a validator for an incoming registration request. - * @param array $data + * + * @param array $data + * * @return \Illuminate\Contracts\Validation\Validator */ protected function validator(array $data) @@ -94,10 +97,13 @@ class RegisterController extends Controller /** * Get a validator for an incoming registration request. - * @param array $data - * @return User + * + * @param array $data + * * @throws \RuntimeException * @throws \Exception + * + * @return User */ protected function create(array $data) { @@ -119,9 +125,12 @@ class RegisterController extends Controller /** * Handle a registration request for the application. + * * @param Request $request - * @return mixed + * * @throws \Exception + * + * @return mixed */ public function register(Request $request) { diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index 87bc20bf..7b758125 100755 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -8,7 +8,6 @@ use Illuminate\Http\Request; /** * Class ResetPasswordController - * @package App\Http\Controllers\Auth */ class ResetPasswordController extends Controller { @@ -19,6 +18,7 @@ class ResetPasswordController extends Controller /** * @param Request $request * @param null $token + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function showResetForm(Request $request, $token = null) @@ -30,6 +30,7 @@ class ResetPasswordController extends Controller /** * Create a new controller instance. + * * @return void */ public function __construct() diff --git a/app/Http/Controllers/Frontend/AcarsController.php b/app/Http/Controllers/Frontend/AcarsController.php index 69cbf1b7..d35cc805 100644 --- a/app/Http/Controllers/Frontend/AcarsController.php +++ b/app/Http/Controllers/Frontend/AcarsController.php @@ -9,15 +9,15 @@ use Illuminate\Http\Request; /** * Class AcarsController - * @package App\Http\Controllers\Frontend */ class AcarsController extends Controller { - private $acarsRepo, - $geoSvc; + private $acarsRepo; + private $geoSvc; /** * AcarsController constructor. + * * @param AcarsRepository $acarsRepo * @param GeoService $geoSvc */ @@ -31,6 +31,7 @@ class AcarsController extends Controller /** * @param Request $request + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index(Request $request) diff --git a/app/Http/Controllers/Frontend/AirportController.php b/app/Http/Controllers/Frontend/AirportController.php index b8479a6b..cfc34388 100644 --- a/app/Http/Controllers/Frontend/AirportController.php +++ b/app/Http/Controllers/Frontend/AirportController.php @@ -3,21 +3,18 @@ namespace App\Http\Controllers\Frontend; use App\Interfaces\Controller; -use App\Models\User; use App\Repositories\AirportRepository; use App\Repositories\FlightRepository; use Flash; -use Illuminate\Database\QueryException; use Request; /** * Class HomeController - * @package App\Http\Controllers\Frontend */ class AirportController extends Controller { - private $airportRepo, - $flightRepo; + private $airportRepo; + private $flightRepo; public function __construct( AirportRepository $airportRepo, @@ -29,6 +26,8 @@ class AirportController extends Controller /** * Show the airport + * + * @param mixed $id */ public function show($id, Request $request) { @@ -53,8 +52,8 @@ class AirportController extends Controller ])->all(); return view('airports.show', [ - 'airport' => $airport, - 'inbound_flights' => $inbound_flights, + 'airport' => $airport, + 'inbound_flights' => $inbound_flights, 'outbound_flights' => $outbound_flights, ]); } diff --git a/app/Http/Controllers/Frontend/DashboardController.php b/app/Http/Controllers/Frontend/DashboardController.php index 69ce6fbf..74b9525e 100644 --- a/app/Http/Controllers/Frontend/DashboardController.php +++ b/app/Http/Controllers/Frontend/DashboardController.php @@ -8,7 +8,6 @@ use Illuminate\Support\Facades\Auth; /** * Class DashboardController - * @package App\Http\Controllers\Frontend */ class DashboardController extends Controller { @@ -16,6 +15,7 @@ class DashboardController extends Controller /** * DashboardController constructor. + * * @param PirepRepository $pirepRepo */ public function __construct(PirepRepository $pirepRepo) diff --git a/app/Http/Controllers/Frontend/DownloadController.php b/app/Http/Controllers/Frontend/DownloadController.php index aa3056a1..28aa0e38 100644 --- a/app/Http/Controllers/Frontend/DownloadController.php +++ b/app/Http/Controllers/Frontend/DownloadController.php @@ -10,7 +10,6 @@ use Illuminate\Support\Facades\Storage; /** * Class DownloadController - * @package App\Http\Controllers\Frontend */ class DownloadController extends Controller { @@ -25,7 +24,7 @@ class DownloadController extends Controller * Group all the files but compound the model with the ID, * since we can have multiple files for every `ref_model` */ - $grouped_files = $files->groupBy(function($item, $key) { + $grouped_files = $files->groupBy(function ($item, $key) { return $item['ref_model'].'_'.$item['ref_model_id']; }); @@ -35,7 +34,7 @@ class DownloadController extends Controller * name of the group to the object instance "name" */ $regrouped_files = []; - foreach($grouped_files as $group => $files) { + foreach ($grouped_files as $group => $files) { [$class, $id] = explode('_', $group); $klass = new $class(); $obj = $klass->find($id); @@ -54,6 +53,8 @@ class DownloadController extends Controller /** * Show the application dashboard. + * + * @param mixed $id */ public function show($id) { @@ -71,10 +72,10 @@ class DownloadController extends Controller return redirect(config('app.login_redirect')); } - ++$file->download_count; + $file->download_count++; $file->save(); - if($file->disk === 'public') { + if ($file->disk === 'public') { $storage = Storage::disk('public'); return $storage->download($file->path, $file->filename); } diff --git a/app/Http/Controllers/Frontend/FlightController.php b/app/Http/Controllers/Frontend/FlightController.php index 79e16171..d4b54a27 100644 --- a/app/Http/Controllers/Frontend/FlightController.php +++ b/app/Http/Controllers/Frontend/FlightController.php @@ -17,17 +17,17 @@ use Prettus\Repository\Exceptions\RepositoryException; /** * Class FlightController - * @package App\Http\Controllers\Frontend */ class FlightController extends Controller { - private $airlineRepo, - $airportRepo, - $flightRepo, - $geoSvc; + private $airlineRepo; + private $airportRepo; + private $flightRepo; + private $geoSvc; /** * FlightController constructor. + * * @param AirlineRepository $airlineRepo * @param AirportRepository $airportRepo * @param FlightRepository $flightRepo @@ -47,6 +47,7 @@ class FlightController extends Controller /** * @param Request $request + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index(Request $request) @@ -56,7 +57,7 @@ class FlightController extends Controller 'visible' => true, ]; - if(setting('pilots.restrict_to_company')) { + if (setting('pilots.restrict_to_company')) { $where['airline_id'] = Auth::user()->airline_id; } @@ -90,7 +91,9 @@ class FlightController extends Controller /** * Find the user's bids and display them + * * @param Request $request + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function bids(Request $request) @@ -111,15 +114,18 @@ class FlightController extends Controller /** * Make a search request using the Repository search + * * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function search(Request $request) { - if(setting('pilots.restrict_to_company')) { + if (setting('pilots.restrict_to_company')) { $this->flightRepo - ->pushCriteria(New WhereCriteria($request, ['airline_id' => Auth::user()->airline_id])) + ->pushCriteria(new WhereCriteria($request, ['airline_id' => Auth::user()->airline_id])) ->paginate(); } @@ -141,7 +147,9 @@ class FlightController extends Controller /** * Show the flight information page + * * @param $id + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View */ public function show($id) diff --git a/app/Http/Controllers/Frontend/HomeController.php b/app/Http/Controllers/Frontend/HomeController.php index 2c47e360..aba33070 100644 --- a/app/Http/Controllers/Frontend/HomeController.php +++ b/app/Http/Controllers/Frontend/HomeController.php @@ -8,7 +8,6 @@ use Illuminate\Database\QueryException; /** * Class HomeController - * @package App\Http\Controllers\Frontend */ class HomeController extends Controller { diff --git a/app/Http/Controllers/Frontend/PirepController.php b/app/Http/Controllers/Frontend/PirepController.php index e900ccb1..a494af7b 100644 --- a/app/Http/Controllers/Frontend/PirepController.php +++ b/app/Http/Controllers/Frontend/PirepController.php @@ -2,7 +2,6 @@ namespace App\Http\Controllers\Frontend; -use App\Exceptions\UserNotAtAirport; use App\Facades\Utils; use App\Http\Requests\CreatePirepRequest; use App\Http\Requests\UpdatePirepRequest; @@ -30,22 +29,22 @@ use PirepStatus; /** * Class PirepController - * @package App\Http\Controllers\Frontend */ class PirepController extends Controller { - private $aircraftRepo, - $airlineRepo, - $fareSvc, - $geoSvc, - $pirepRepo, - $airportRepo, - $pirepFieldRepo, - $pirepSvc, - $userSvc; + private $aircraftRepo; + private $airlineRepo; + private $fareSvc; + private $geoSvc; + private $pirepRepo; + private $airportRepo; + private $pirepFieldRepo; + private $pirepSvc; + private $userSvc; /** * PirepController constructor. + * * @param AircraftRepository $aircraftRepo * @param AirlineRepository $airlineRepo * @param AirportRepository $airportRepo @@ -81,7 +80,10 @@ class PirepController extends Controller /** * Dropdown with aircraft grouped by subfleet - * @param null $user + * + * @param null $user + * @param mixed $add_blank + * * @return array */ public function aircraftList($user = null, $add_blank = false) @@ -107,6 +109,7 @@ class PirepController extends Controller /** * Save any custom fields found + * * @param Pirep $pirep * @param Request $request */ @@ -123,7 +126,7 @@ class PirepController extends Controller 'name' => $field->name, 'slug' => $field->slug, 'value' => $request->input($field->slug), - 'source' => PirepSource::MANUAL + 'source' => PirepSource::MANUAL, ]; } @@ -133,8 +136,10 @@ class PirepController extends Controller /** * Save the fares that have been specified/saved + * * @param Pirep $pirep * @param Request $request + * * @throws \Exception */ protected function saveFares(Pirep $pirep, Request $request) @@ -163,8 +168,10 @@ class PirepController extends Controller /** * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index(Request $request) { @@ -184,6 +191,7 @@ class PirepController extends Controller /** * @param $id + * * @return mixed */ public function show($id) @@ -204,7 +212,9 @@ class PirepController extends Controller /** * Return the fares form for a given aircraft + * * @param Request $request + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function fares(Request $request) @@ -220,6 +230,7 @@ class PirepController extends Controller /** * Create a new flight report + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function create() @@ -239,8 +250,10 @@ class PirepController extends Controller /** * @param CreatePirepRequest $request - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * * @throws \Exception + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store(CreatePirepRequest $request) { @@ -251,8 +264,8 @@ class PirepController extends Controller $attrs = $request->all(); $attrs['submit'] = strtolower($attrs['submit']); - if($attrs['submit'] === 'submit') { - # Are they allowed at this airport? + if ($attrs['submit'] === 'submit') { + // Are they allowed at this airport? if (setting('pilots.only_flights_from_current') && Auth::user()->curr_airport_id !== $pirep->dpt_airport_id) { return $this->flashError( @@ -261,7 +274,7 @@ class PirepController extends Controller ); } - # Can they fly this aircraft? + // Can they fly this aircraft? if (setting('pireps.restrict_aircraft_to_rank', false) && !$this->userSvc->aircraftAllowed(Auth::user(), $pirep->aircraft_id)) { return $this->flashError( @@ -270,7 +283,7 @@ class PirepController extends Controller ); } - # is the aircraft in the right place? + // is the aircraft in the right place? if (setting('pireps.only_aircraft_at_dpt_airport') && $pirep->aircraft_id !== $pirep->dpt_airport_id) { return $this->flashError( @@ -279,7 +292,7 @@ class PirepController extends Controller ); } - # Make sure this isn't a duplicate + // Make sure this isn't a duplicate $dupe_pirep = $this->pirepSvc->findDuplicate($pirep); if ($dupe_pirep !== false) { return $this->flashError( @@ -305,13 +318,13 @@ class PirepController extends Controller // Depending on the button they selected, set an initial state // Can be saved as a draft or just submitted if ($attrs['submit'] === 'save') { - if(!$pirep->read_only) { + if (!$pirep->read_only) { $pirep->state = PirepState::DRAFT; } $pirep->save(); Flash::success('PIREP saved successfully.'); - } else if ($attrs['submit'] === 'submit') { + } elseif ($attrs['submit'] === 'submit') { $this->pirepSvc->submit($pirep); Flash::success('PIREP submitted!'); } @@ -321,7 +334,9 @@ class PirepController extends Controller /** * Show the form for editing the specified Pirep. - * @param int $id + * + * @param int $id + * * @return mixed */ public function edit($id) @@ -332,16 +347,16 @@ class PirepController extends Controller return redirect(route('frontend.pireps.index')); } - # Eager load the subfleet and fares under it + // Eager load the subfleet and fares under it $pirep->aircraft->load('subfleet.fares'); $time = new Time($pirep->flight_time); $pirep->hours = $time->hours; $pirep->minutes = $time->minutes; - # set the custom fields + // set the custom fields foreach ($pirep->fields as $field) { - if($field->slug == null) { + if ($field->slug == null) { $field->slug = str_slug($field->name); } @@ -349,7 +364,7 @@ class PirepController extends Controller $pirep->{$field_name} = $field->value; } - # set the fares + // set the fares foreach ($pirep->fares as $fare) { $field_name = 'fare_'.$fare->fare_id; $pirep->{$field_name} = $fare->count; @@ -368,9 +383,11 @@ class PirepController extends Controller /** * @param $id * @param UpdatePirepRequest $request - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * * @throws \Prettus\Validator\Exceptions\ValidatorException * @throws \Exception + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update($id, UpdatePirepRequest $request) { @@ -384,7 +401,7 @@ class PirepController extends Controller $attrs = $request->all(); $attrs['submit'] = strtolower($attrs['submit']); - # Fix the time + // Fix the time $attrs['flight_time'] = Time::init( $attrs['minutes'], $attrs['hours'])->getMinutes(); @@ -399,12 +416,12 @@ class PirepController extends Controller $this->saveCustomFields($pirep, $request); $this->saveFares($pirep, $request); - if($attrs['submit'] === 'save') { + if ($attrs['submit'] === 'save') { Flash::success('PIREP saved successfully.'); - } else if($attrs['submit'] === 'submit') { + } elseif ($attrs['submit'] === 'submit') { $this->pirepSvc->submit($pirep); Flash::success('PIREP submitted!'); - } else if($attrs['submit'] === 'delete' || $attrs['submit'] === 'cancel') { + } elseif ($attrs['submit'] === 'delete' || $attrs['submit'] === 'cancel') { $this->pirepRepo->update([ 'state' => PirepState::CANCELLED, 'status' => PirepStatus::CANCELLED, @@ -419,8 +436,10 @@ class PirepController extends Controller /** * Submit the PIREP + * * @param $id * @param Request $request + * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function submit($id, Request $request) diff --git a/app/Http/Controllers/Frontend/ProfileController.php b/app/Http/Controllers/Frontend/ProfileController.php index 286a7dd7..c4257b52 100644 --- a/app/Http/Controllers/Frontend/ProfileController.php +++ b/app/Http/Controllers/Frontend/ProfileController.php @@ -13,24 +13,24 @@ use Flash; use Hash; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Storage; +use Intervention\Image\Facades\Image; use Jackiedo\Timezonelist\Facades\Timezonelist; use Log; use Validator; -use Intervention\Image\Facades\Image; -use Illuminate\Support\Facades\Storage; /** * Class ProfileController - * @package App\Http\Controllers\Frontend */ class ProfileController extends Controller { - private $airlineRepo, - $airportRepo, - $userRepo; + private $airlineRepo; + private $airportRepo; + private $userRepo; /** * ProfileController constructor. + * * @param AirlineRepository $airlineRepo * @param AirportRepository $airportRepo * @param UserRepository $userRepo @@ -64,6 +64,7 @@ class ProfileController extends Controller /** * @param $id + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View */ public function show($id) @@ -85,7 +86,9 @@ class ProfileController extends Controller /** * Show the edit for form the user's profile + * * @param Request $request + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View */ public function edit(Request $request) @@ -111,8 +114,10 @@ class ProfileController extends Controller /** * @param Request $request - * @return $this + * * @throws \Prettus\Validator\Exceptions\ValidatorException + * + * @return $this */ public function update(Request $request) { @@ -148,7 +153,7 @@ class ProfileController extends Controller } if ($request->hasFile('avatar')) { $avatar = $request->file('avatar'); - $file_name = $user->pilot_id . '.' .$avatar->getClientOriginalExtension(); + $file_name = $user->pilot_id.'.'.$avatar->getClientOriginalExtension(); $path = "avatars/{$file_name}"; Image::make($avatar)->resize(config('phpvms.avatar.width'), config('phpvms.avatar.height'))->save(public_path('uploads/avatars/'.$file_name)); $req_data['avatar'] = $path; @@ -163,7 +168,9 @@ class ProfileController extends Controller /** * Regenerate the user's API key + * * @param Request $request + * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function regen_apikey(Request $request) diff --git a/app/Http/Controllers/Frontend/UserController.php b/app/Http/Controllers/Frontend/UserController.php index e7b43ec6..679bed8a 100644 --- a/app/Http/Controllers/Frontend/UserController.php +++ b/app/Http/Controllers/Frontend/UserController.php @@ -8,7 +8,6 @@ use Illuminate\Http\Request; /** * Class UserController - * @package App\Http\Controllers\Frontend */ class UserController extends Controller { @@ -16,6 +15,7 @@ class UserController extends Controller /** * UserController constructor. + * * @param UserRepository $userRepo */ public function __construct( @@ -26,6 +26,7 @@ class UserController extends Controller /** * @param Request $request + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index(Request $request) diff --git a/app/Http/Middleware/ApiAuth.php b/app/Http/Middleware/ApiAuth.php index 08abc31e..5064e8b8 100644 --- a/app/Http/Middleware/ApiAuth.php +++ b/app/Http/Middleware/ApiAuth.php @@ -15,8 +15,9 @@ class ApiAuth /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * * @return mixed */ public function handle($request, Closure $next) @@ -52,6 +53,9 @@ class ApiAuth /** * Return an unauthorized message + * + * @param mixed $details + * * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response */ private function unauthorized($details = '') diff --git a/app/Http/Middleware/MeasureExecutionTime.php b/app/Http/Middleware/MeasureExecutionTime.php index 2a6ca73f..b83329d6 100644 --- a/app/Http/Middleware/MeasureExecutionTime.php +++ b/app/Http/Middleware/MeasureExecutionTime.php @@ -12,8 +12,8 @@ class MeasureExecutionTime /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param \Illuminate\Http\Request $request + * @param \Closure $next * * @return mixed */ diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 8b10025e..abb8423b 100755 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -10,9 +10,10 @@ class RedirectIfAuthenticated /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @param string|null $guard + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @param string|null $guard + * * @return mixed */ public function handle($request, Closure $next, $guard = null) diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 1ab3b7f6..0faba9ee 100755 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -8,6 +8,7 @@ class VerifyCsrfToken extends BaseVerifier { /** * The URIs that should be excluded from CSRF verification. + * * @var array */ protected $except = [ diff --git a/app/Http/Requests/Acars/CommentRequest.php b/app/Http/Requests/Acars/CommentRequest.php index a80013d0..83feded9 100644 --- a/app/Http/Requests/Acars/CommentRequest.php +++ b/app/Http/Requests/Acars/CommentRequest.php @@ -6,13 +6,12 @@ use App\Interfaces\FormRequest; /** * Class FileRequest - * @package App\Http\Requests\Acars */ class CommentRequest extends FormRequest { public function authorize() { - return true; # Anyone can comment + return true; // Anyone can comment } public function rules() diff --git a/app/Http/Requests/Acars/EventRequest.php b/app/Http/Requests/Acars/EventRequest.php index a0e8614b..94447e64 100644 --- a/app/Http/Requests/Acars/EventRequest.php +++ b/app/Http/Requests/Acars/EventRequest.php @@ -8,13 +8,13 @@ use Auth; /** * Class EventRequest - * @package App\Http\Requests\Acars */ class EventRequest extends FormRequest { /** - * @return bool * @throws \Illuminate\Database\Eloquent\ModelNotFoundException + * + * @return bool */ public function authorize() { diff --git a/app/Http/Requests/Acars/FieldsRequest.php b/app/Http/Requests/Acars/FieldsRequest.php index fc220e17..683469ae 100644 --- a/app/Http/Requests/Acars/FieldsRequest.php +++ b/app/Http/Requests/Acars/FieldsRequest.php @@ -6,7 +6,6 @@ use App\Interfaces\FormRequest; /** * Class PrefileRequest - * @package App\Http\Requests\Acars */ class FieldsRequest extends FormRequest { diff --git a/app/Http/Requests/Acars/FileRequest.php b/app/Http/Requests/Acars/FileRequest.php index 54055fe5..4e857afc 100644 --- a/app/Http/Requests/Acars/FileRequest.php +++ b/app/Http/Requests/Acars/FileRequest.php @@ -8,7 +8,6 @@ use Auth; /** * Class FileRequest - * @package App\Http\Requests\Acars */ class FileRequest extends FormRequest { @@ -48,10 +47,10 @@ class FileRequest extends FormRequest 'block_on_time' => 'nullable|date', 'created_at' => 'nullable|date', - # See if the fare objects are included and formatted properly - 'fares' => 'nullable|array', - 'fares.*.id' => 'required', - 'fares.*.count' => 'required|numeric', + // See if the fare objects are included and formatted properly + 'fares' => 'nullable|array', + 'fares.*.id' => 'required', + 'fares.*.count' => 'required|numeric', ]; return $rules; diff --git a/app/Http/Requests/Acars/LogRequest.php b/app/Http/Requests/Acars/LogRequest.php index 7adeb309..9964ca82 100644 --- a/app/Http/Requests/Acars/LogRequest.php +++ b/app/Http/Requests/Acars/LogRequest.php @@ -8,7 +8,6 @@ use Auth; /** * Class LogRequest - * @package App\Http\Requests\Acars */ class LogRequest extends FormRequest { diff --git a/app/Http/Requests/Acars/PositionRequest.php b/app/Http/Requests/Acars/PositionRequest.php index d2623a6e..5aef5163 100644 --- a/app/Http/Requests/Acars/PositionRequest.php +++ b/app/Http/Requests/Acars/PositionRequest.php @@ -9,7 +9,6 @@ use Auth; /** * Class PositionRequest - * @package App\Http\Requests\Acars */ class PositionRequest extends FormRequest { diff --git a/app/Http/Requests/Acars/PrefileRequest.php b/app/Http/Requests/Acars/PrefileRequest.php index fdbf2722..14d7c989 100644 --- a/app/Http/Requests/Acars/PrefileRequest.php +++ b/app/Http/Requests/Acars/PrefileRequest.php @@ -7,7 +7,6 @@ use App\Models\Pirep; /** * Class PrefileRequest - * @package App\Http\Requests\Acars */ class PrefileRequest extends FormRequest { @@ -51,10 +50,10 @@ class PrefileRequest extends FormRequest 'block_on_time' => 'nullable|date', 'created_at' => 'nullable|date', - # See if the fare objects are included and formatted properly - 'fares' => 'nullable|array', - 'fares.*.id' => 'required', - 'fares.*.count' => 'required|numeric', + // See if the fare objects are included and formatted properly + 'fares' => 'nullable|array', + 'fares.*.id' => 'required', + 'fares.*.count' => 'required|numeric', ]; return $rules; diff --git a/app/Http/Requests/Acars/RouteRequest.php b/app/Http/Requests/Acars/RouteRequest.php index f50821b2..8d70027e 100644 --- a/app/Http/Requests/Acars/RouteRequest.php +++ b/app/Http/Requests/Acars/RouteRequest.php @@ -8,7 +8,6 @@ use Auth; /** * Class RouteRequest - * @package App\Http\Requests\Acars */ class RouteRequest extends FormRequest { diff --git a/app/Http/Requests/Acars/UpdateRequest.php b/app/Http/Requests/Acars/UpdateRequest.php index 4a1d7985..926b2b20 100644 --- a/app/Http/Requests/Acars/UpdateRequest.php +++ b/app/Http/Requests/Acars/UpdateRequest.php @@ -8,7 +8,6 @@ use Auth; /** * Class UpdateRequest - * @package App\Http\Requests\Acars */ class UpdateRequest extends FormRequest { @@ -48,10 +47,10 @@ class UpdateRequest extends FormRequest 'status' => 'nullable', 'score' => 'nullable|integer', - # See if the fare objects are included and formatted properly - 'fares' => 'nullable|array', - 'fares.*.id' => 'required', - 'fares.*.count' => 'required|numeric', + // See if the fare objects are included and formatted properly + 'fares' => 'nullable|array', + 'fares.*.id' => 'required', + 'fares.*.count' => 'required|numeric', ]; return $rules; diff --git a/app/Http/Requests/CreateAircraftRequest.php b/app/Http/Requests/CreateAircraftRequest.php index 09d7b4cf..6f8fa34d 100644 --- a/app/Http/Requests/CreateAircraftRequest.php +++ b/app/Http/Requests/CreateAircraftRequest.php @@ -9,6 +9,7 @@ class CreateAircraftRequest extends FormRequest { /** * Determine if the user is authorized to make this request. + * * @return bool */ public function authorize(): bool @@ -18,6 +19,7 @@ class CreateAircraftRequest extends FormRequest /** * Get the validation rules that apply to the request. + * * @return array */ public function rules(): array diff --git a/app/Http/Requests/CreateAirportRequest.php b/app/Http/Requests/CreateAirportRequest.php index 869cc11c..5894cc1d 100644 --- a/app/Http/Requests/CreateAirportRequest.php +++ b/app/Http/Requests/CreateAirportRequest.php @@ -7,12 +7,12 @@ use Illuminate\Foundation\Http\FormRequest; /** * Class CreateAirportRequest - * @package App\Http\Requests */ class CreateAirportRequest extends FormRequest { /** * Determine if the user is authorized to make this request. + * * @return bool */ public function authorize(): bool @@ -22,6 +22,7 @@ class CreateAirportRequest extends FormRequest /** * Get the validation rules that apply to the request. + * * @return array */ public function rules(): array diff --git a/app/Http/Requests/CreateFareRequest.php b/app/Http/Requests/CreateFareRequest.php index 8271ffea..7b01a635 100644 --- a/app/Http/Requests/CreateFareRequest.php +++ b/app/Http/Requests/CreateFareRequest.php @@ -9,6 +9,7 @@ class CreateFareRequest extends FormRequest { /** * Determine if the user is authorized to make this request. + * * @return bool */ public function authorize(): bool @@ -18,6 +19,7 @@ class CreateFareRequest extends FormRequest /** * Get the validation rules that apply to the request. + * * @return array */ public function rules(): array diff --git a/app/Http/Requests/CreatePirepRequest.php b/app/Http/Requests/CreatePirepRequest.php index 415ccd3e..5a2b39b2 100644 --- a/app/Http/Requests/CreatePirepRequest.php +++ b/app/Http/Requests/CreatePirepRequest.php @@ -28,7 +28,7 @@ class CreatePirepRequest extends FormRequest { // Don't run validations if it's just being saved $action = strtolower(request('submit', 'submit')); - if($action === 'save') { + if ($action === 'save') { return [ 'airline_id' => 'required|exists:airlines,id', 'flight_number' => 'required', @@ -42,7 +42,7 @@ class CreatePirepRequest extends FormRequest $field_rules['hours'] = 'nullable|integer'; $field_rules['minutes'] = 'nullable|integer'; - # Add the validation rules for the custom fields + // Add the validation rules for the custom fields $pirepFieldRepo = app(PirepFieldRepository::class); $custom_fields = $pirepFieldRepo->all(); diff --git a/app/Http/Requests/CreateSubfleetRequest.php b/app/Http/Requests/CreateSubfleetRequest.php index 92c9094e..073cacf9 100644 --- a/app/Http/Requests/CreateSubfleetRequest.php +++ b/app/Http/Requests/CreateSubfleetRequest.php @@ -9,6 +9,7 @@ class CreateSubfleetRequest extends FormRequest { /** * Determine if the user is authorized to make this request. + * * @return bool */ public function authorize(): bool @@ -18,6 +19,7 @@ class CreateSubfleetRequest extends FormRequest /** * Get the validation rules that apply to the request. + * * @return array */ public function rules(): array diff --git a/app/Http/Requests/CreateUserRequest.php b/app/Http/Requests/CreateUserRequest.php index 4570fdb4..a1ad752c 100644 --- a/app/Http/Requests/CreateUserRequest.php +++ b/app/Http/Requests/CreateUserRequest.php @@ -9,6 +9,7 @@ class CreateUserRequest extends FormRequest { /** * Determine if the user is authorized to make this request. + * * @return bool */ public function authorize(): bool @@ -18,6 +19,7 @@ class CreateUserRequest extends FormRequest /** * Get the validation rules that apply to the request. + * * @return array */ public function rules(): array diff --git a/app/Http/Requests/ImportRequest.php b/app/Http/Requests/ImportRequest.php index a1c45632..fc60f04b 100644 --- a/app/Http/Requests/ImportRequest.php +++ b/app/Http/Requests/ImportRequest.php @@ -7,16 +7,16 @@ use Illuminate\Http\Request; /** * Validate that the files are imported - * @package App\Http\Requests */ class ImportRequest extends FormRequest { public static $rules = [ - 'csv_file' => 'required|file', + 'csv_file' => 'required|file', ]; /** * @param Request $request + * * @throws \Illuminate\Validation\ValidationException */ public static function validate(Request $request) diff --git a/app/Http/Requests/UpdateFilesRequest.php b/app/Http/Requests/UpdateFilesRequest.php index 137c90a2..fa183d3e 100644 --- a/app/Http/Requests/UpdateFilesRequest.php +++ b/app/Http/Requests/UpdateFilesRequest.php @@ -6,12 +6,12 @@ use Illuminate\Foundation\Http\FormRequest; /** * Class CreateFilesRequest - * @package App\Http\Requests */ class UpdateFilesRequest extends FormRequest { /** * Determine if the user is authorized to make this request. + * * @return bool */ public function authorize(): bool @@ -21,6 +21,7 @@ class UpdateFilesRequest extends FormRequest /** * Get the validation rules that apply to the request. + * * @return array */ public function rules(): array @@ -29,7 +30,7 @@ class UpdateFilesRequest extends FormRequest 'name' => 'required', 'file' => 'nullable|file', - #'files.*' => 'required|file', + //'files.*' => 'required|file', ]; } } diff --git a/app/Http/Requests/UpdatePirepRequest.php b/app/Http/Requests/UpdatePirepRequest.php index 0b6b4b89..29fd0ebe 100644 --- a/app/Http/Requests/UpdatePirepRequest.php +++ b/app/Http/Requests/UpdatePirepRequest.php @@ -42,7 +42,7 @@ class UpdatePirepRequest extends FormRequest $field_rules['hours'] = 'nullable|integer'; $field_rules['minutes'] = 'nullable|integer'; - # Add the validation rules for the custom fields + // Add the validation rules for the custom fields $pirepFieldRepo = app(PirepFieldRepository::class); $custom_fields = $pirepFieldRepo->all(); diff --git a/app/Http/Resources/Acars.php b/app/Http/Resources/Acars.php index 12b17ff0..e4602d37 100644 --- a/app/Http/Resources/Acars.php +++ b/app/Http/Resources/Acars.php @@ -11,7 +11,8 @@ class Acars extends Resource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return array */ public function toArray($request) diff --git a/app/Http/Resources/AcarsLog.php b/app/Http/Resources/AcarsLog.php index 55eff275..3d86cf23 100644 --- a/app/Http/Resources/AcarsLog.php +++ b/app/Http/Resources/AcarsLog.php @@ -7,7 +7,6 @@ use Illuminate\Http\Resources\Json\Resource; /** * ACARS table but only include the fields for the routes * Class AcarsRoute - * @package App\Http\Resources */ class AcarsLog extends Resource { diff --git a/app/Http/Resources/AcarsRoute.php b/app/Http/Resources/AcarsRoute.php index a1795f16..9e756683 100644 --- a/app/Http/Resources/AcarsRoute.php +++ b/app/Http/Resources/AcarsRoute.php @@ -7,7 +7,6 @@ use Illuminate\Http\Resources\Json\Resource; /** * ACARS table but only include the fields for the routes * Class AcarsRoute - * @package App\Http\Resources */ class AcarsRoute extends Resource { diff --git a/app/Http/Resources/Airline.php b/app/Http/Resources/Airline.php index 2f945c4b..50ad22ae 100644 --- a/app/Http/Resources/Airline.php +++ b/app/Http/Resources/Airline.php @@ -15,9 +15,9 @@ class Airline extends Resource 'name' => $this->name, 'country' => $this->country, 'logo' => $this->logo, - #'active' => $this->active, - #'created_at' => $this->created_at, - #'updated_at' => $this->updated_at, + //'active' => $this->active, + //'created_at' => $this->created_at, + //'updated_at' => $this->updated_at, ]; } } diff --git a/app/Http/Resources/Flight.php b/app/Http/Resources/Flight.php index 1fd9cff7..4d235984 100644 --- a/app/Http/Resources/Flight.php +++ b/app/Http/Resources/Flight.php @@ -9,6 +9,7 @@ class Flight extends Resource { /** * Set the fields on the flight object + * * @return array */ private function setFields() diff --git a/app/Http/Resources/News.php b/app/Http/Resources/News.php index 8262b310..a5f94272 100644 --- a/app/Http/Resources/News.php +++ b/app/Http/Resources/News.php @@ -6,23 +6,22 @@ use Illuminate\Http\Resources\Json\Resource; /** * Class Response - * @package App\Http\Resources - * Generic response resource */ class News extends Resource { /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return array */ public function toArray($request) { $resp = parent::toArray($request); $resp['user'] = [ - 'id' => $this->user->id, - 'name' => $this->user->name, + 'id' => $this->user->id, + 'name' => $this->user->name, ]; return $resp; diff --git a/app/Http/Resources/Pirep.php b/app/Http/Resources/Pirep.php index 2e00a55a..7930b255 100644 --- a/app/Http/Resources/Pirep.php +++ b/app/Http/Resources/Pirep.php @@ -12,7 +12,8 @@ class Pirep extends Resource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return array */ public function toArray($request) @@ -37,11 +38,13 @@ class Pirep extends Resource * Relationship fields */ - if($this->block_on_time) + if ($this->block_on_time) { $pirep['block_on_time'] = $this->block_on_time->toIso8601ZuluString(); + } - if($this->block_off_time) + if ($this->block_off_time) { $pirep['block_off_time'] = $this->block_off_time->toIso8601ZuluString(); + } $pirep['status_text'] = PirepStatus::label($this->status); @@ -58,7 +61,7 @@ class Pirep extends Resource 'curr_airport_id' => $this->user->curr_airport_id, ]; - # format to kvp + // format to kvp $pirep['fields'] = new PirepFieldCollection($this->fields); return $pirep; diff --git a/app/Http/Resources/PirepComment.php b/app/Http/Resources/PirepComment.php index d2464b89..58336a5b 100644 --- a/app/Http/Resources/PirepComment.php +++ b/app/Http/Resources/PirepComment.php @@ -6,15 +6,14 @@ use Illuminate\Http\Resources\Json\Resource; /** * Class Response - * @package App\Http\Resources - * Generic response resource */ class PirepComment extends Resource { /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return array */ public function toArray($request) diff --git a/app/Http/Resources/PirepFieldCollection.php b/app/Http/Resources/PirepFieldCollection.php index 7456c75b..8186fa45 100644 --- a/app/Http/Resources/PirepFieldCollection.php +++ b/app/Http/Resources/PirepFieldCollection.php @@ -6,14 +6,13 @@ use Illuminate\Http\Resources\Json\ResourceCollection; /** * Class PirepFieldCollection - * @package App\Http\Resources */ class PirepFieldCollection extends ResourceCollection { public function toArray($request) { $obj = []; - foreach($this->collection as $field) { + foreach ($this->collection as $field) { $obj[$field->name] = $field->value; } diff --git a/app/Http/Resources/Rank.php b/app/Http/Resources/Rank.php index 23d91d56..4d3d0777 100644 --- a/app/Http/Resources/Rank.php +++ b/app/Http/Resources/Rank.php @@ -9,7 +9,8 @@ class Rank extends Resource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return array */ public function toArray($request) diff --git a/app/Http/Resources/Response.php b/app/Http/Resources/Response.php index b2c89651..bbf0cc65 100644 --- a/app/Http/Resources/Response.php +++ b/app/Http/Resources/Response.php @@ -6,15 +6,14 @@ use Illuminate\Http\Resources\Json\Resource; /** * Class Response - * @package App\Http\Resources - * Generic response resource */ class Response extends Resource { /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return array */ public function toArray($request) diff --git a/app/Http/Resources/UserBid.php b/app/Http/Resources/UserBid.php index 3c87fdfc..59207823 100644 --- a/app/Http/Resources/UserBid.php +++ b/app/Http/Resources/UserBid.php @@ -12,9 +12,9 @@ class UserBid extends Resource 'id' => $this->id, 'user_id' => $this->user_id, 'flight_id' => $this->flight_id, - 'flights' => Flight::collection($this->whenLoaded('flight')) - #'created_at' => $this->created_at, - #'updated_at' => $this->updated_at, + 'flights' => Flight::collection($this->whenLoaded('flight')), + //'created_at' => $this->created_at, + //'updated_at' => $this->updated_at, ]; } } diff --git a/app/Interfaces/Award.php b/app/Interfaces/Award.php index 5e43e739..389cc4aa 100644 --- a/app/Interfaces/Award.php +++ b/app/Interfaces/Award.php @@ -15,7 +15,6 @@ use Log; * public function check($parameter=null) * * See: http://docs.phpvms.net/customizing/awards - * @package App\Interfaces */ abstract class Award { @@ -25,7 +24,9 @@ abstract class Award /** * Each award class just needs to return true or false if it should actually * be awarded to a user. This is the only method that needs to be implemented + * * @param null $parameter Optional parameters that are passed in from the UI + * * @return bool */ abstract public function check($parameter = null): bool; @@ -34,11 +35,12 @@ abstract class Award * You don't really need to mess with anything below here */ - protected $award, - $user; + protected $award; + protected $user; /** * AwardInterface constructor. + * * @param AwardModel $award * @param User $user */ @@ -55,7 +57,7 @@ abstract class Award */ final public function handle(): void { - # Check if the params are a JSON object or array + // Check if the params are a JSON object or array $param = $this->award->ref_model_params; if (Utils::isObject($this->award->ref_model_params)) { $param = json_decode($this->award->ref_model_params); @@ -68,6 +70,7 @@ abstract class Award /** * Add the award to this user, if they don't already have it + * * @return bool|UserAward */ final protected function addAward() @@ -87,13 +90,13 @@ abstract class Award try { $award->save(); - } catch(\Exception $e) { + } catch (\Exception $e) { Log::error( 'Error saving award: '.$e->getMessage(), $e->getTrace() ); - return null; + return; } return $award; diff --git a/app/Interfaces/Controller.php b/app/Interfaces/Controller.php index 76d66942..4cd35885 100755 --- a/app/Interfaces/Controller.php +++ b/app/Interfaces/Controller.php @@ -9,7 +9,6 @@ use Illuminate\Http\Request; /** * Class Controller - * @package App\Http\Controllers */ abstract class Controller extends \Illuminate\Routing\Controller { @@ -17,8 +16,10 @@ abstract class Controller extends \Illuminate\Routing\Controller /** * Write a error to the flash and redirect the user to a route + * * @param $message * @param $route + * * @return mixed */ public function flashError($message, $route) @@ -29,15 +30,18 @@ abstract class Controller extends \Illuminate\Routing\Controller /** * Shortcut function to get the attributes from a request while running the validations + * * @param Request $request * @param array $attrs_or_validations * @param array $addtl_fields - * @return array + * * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException + * + * @return array */ public function getFromReq($request, $attrs_or_validations, $addtl_fields = null) { - # See if a list of values is passed in, or if a validation list is passed in + // See if a list of values is passed in, or if a validation list is passed in $is_validation = false; if (\count(array_filter(array_keys($attrs_or_validations), '\is_string')) > 0) { $is_validation = true; @@ -73,13 +77,16 @@ abstract class Controller extends \Illuminate\Routing\Controller /** * Simple normalized method for forming the JSON responses + * * @param $message + * @param null|mixed $count + * * @return \Illuminate\Http\JsonResponse */ public function message($message, $count = null) { $attrs = [ - 'message' => $message + 'message' => $message, ]; if ($count !== null) { diff --git a/app/Interfaces/Enum.php b/app/Interfaces/Enum.php index fc82547e..72778b30 100644 --- a/app/Interfaces/Enum.php +++ b/app/Interfaces/Enum.php @@ -4,7 +4,6 @@ namespace App\Interfaces; /** * Borrowed some ideas from myclabs/php-enum after this was created - * @package App\Models\Enums */ abstract class Enum { @@ -13,12 +12,13 @@ abstract class Enum protected static $labels = []; /** - * @var integer + * @var int */ protected $value; /** * Create an instance of this Enum + * * @param $val */ public function __construct($val) @@ -28,6 +28,7 @@ abstract class Enum /** * Return the value that's been set if this is an instance + * * @return mixed */ final public function getValue() @@ -37,7 +38,9 @@ abstract class Enum /** * Return the label, try to return the translated version as well + * * @param $value + * * @return mixed */ final public static function label($value) @@ -62,7 +65,9 @@ abstract class Enum /** * Get the numeric value from a string code + * * @param $code + * * @return mixed|null */ public static function getFromCode($code) @@ -72,14 +77,16 @@ abstract class Enum /** * Convert the integer value into one of the codes + * * @param $value + * * @return false|int|string */ public static function convertToCode($value) { $value = (int) $value; if (!array_key_exists($value, static::$codes)) { - return null; + return; } return static::$codes[$value]; @@ -87,7 +94,9 @@ abstract class Enum /** * Select box entry items - * @param bool $add_blank + * + * @param bool $add_blank + * * @return array */ public static function select($add_blank = false): array @@ -106,8 +115,10 @@ abstract class Enum /** * Returns all possible values as an array - * @return array Constant name in key, constant value in value + * * @throws \ReflectionException + * + * @return array Constant name in key, constant value in value */ public static function toArray(): array { @@ -122,9 +133,10 @@ abstract class Enum /** * @param Enum $enum + * * @return bool */ - final public function equals(Enum $enum): bool + final public function equals(self $enum): bool { return $this->getValue() === $enum->getValue() && get_called_class() == get_class($enum); } @@ -132,11 +144,14 @@ abstract class Enum /** * Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a * class constant + * * @param string $name * @param array $arguments - * @return static + * * @throws \BadMethodCallException * @throws \ReflectionException + * + * @return static */ public static function __callStatic($name, $arguments) { @@ -144,6 +159,7 @@ abstract class Enum if (isset($array[$name])) { return new static($array[$name]); } + throw new \BadMethodCallException( "No static method or enum constant '$name' in class ".get_called_class() ); diff --git a/app/Interfaces/FormRequest.php b/app/Interfaces/FormRequest.php index 4402e905..d1f75d5c 100644 --- a/app/Interfaces/FormRequest.php +++ b/app/Interfaces/FormRequest.php @@ -4,7 +4,6 @@ namespace App\Interfaces; /** * Class FormRequest - * @package App\Interfaces */ class FormRequest extends \Illuminate\Foundation\Http\FormRequest { diff --git a/app/Interfaces/ImportExport.php b/app/Interfaces/ImportExport.php index 80f2f33d..0b25a15b 100644 --- a/app/Interfaces/ImportExport.php +++ b/app/Interfaces/ImportExport.php @@ -9,14 +9,13 @@ use Validator; /** * Common functionality used across all of the importers - * @package App\Interfaces */ class ImportExport { public $assetType; public $status = [ 'success' => [], - 'errors' => [], + 'errors' => [], ]; /** @@ -26,6 +25,7 @@ class ImportExport /** * @param mixed $row + * * @return array */ public function export($row): array @@ -36,8 +36,10 @@ class ImportExport /** * @param array $row * @param mixed $index - * @return bool + * * @throws \RuntimeException + * + * @return bool */ public function import(array $row, $index): bool { @@ -46,7 +48,9 @@ class ImportExport /** * Get the airline from the ICAO. Create it if it doesn't exist + * * @param $code + * * @return Airline */ public function getAirline($code) @@ -68,7 +72,9 @@ class ImportExport /** * Do a basic check that the number of columns match + * * @param $row + * * @return bool */ public function checkColumns($row): bool @@ -78,8 +84,10 @@ class ImportExport /** * Bubble up an error to the interface that we need to stop + * * @param $error * @param $e + * * @throws ValidationException */ protected function throwError($error, \Exception $e = null): void @@ -91,11 +99,13 @@ class ImportExport $validator = Validator::make([], []); $validator->errors()->add('csv_file', $error); + throw new ValidationException($validator); } /** * Add to the log messages for this importer + * * @param $msg */ public function log($msg): void @@ -106,6 +116,7 @@ class ImportExport /** * Add to the error log for this import + * * @param $msg */ public function errorLog($msg): void @@ -116,15 +127,16 @@ class ImportExport /** * Set a key-value pair to an array + * * @param $kvp_str * @param array $arr */ protected function kvpToArray($kvp_str, array &$arr) { $item = explode('=', $kvp_str); - if (\count($item) === 1) { # just a list? + if (\count($item) === 1) { // just a list? $arr[] = trim($item[0]); - } else { # actually a key-value pair + } else { // actually a key-value pair $k = trim($item[0]); $v = trim($item[1]); $arr[$k] = $v; @@ -140,6 +152,7 @@ class ImportExport * Converted into a multi-dimensional array * * @param $field + * * @return array|string */ public function parseMultiColumnValues($field) @@ -147,9 +160,9 @@ class ImportExport $ret = []; $split_values = explode(';', $field); - # No multiple values in here, just a straight value + // No multiple values in here, just a straight value if (\count($split_values) === 1) { - if(trim($split_values[0]) === '') { + if (trim($split_values[0]) === '') { return []; } @@ -157,15 +170,15 @@ class ImportExport } foreach ($split_values as $value) { - # This isn't in the query string format, so it's - # just a straight key-value pair set + // This isn't in the query string format, so it's + // just a straight key-value pair set if (strpos($value, '?') === false) { $this->kvpToArray($value, $ret); continue; } - # This contains the query string, which turns it - # into the multi-level array + // This contains the query string, which turns it + // into the multi-level array $query_str = explode('?', $value); $parent = trim($query_str[0]); @@ -173,7 +186,7 @@ class ImportExport $children = []; $kvp = explode('&', trim($query_str[1])); foreach ($kvp as $items) { - if(!$items) { + if (!$items) { continue; } @@ -188,30 +201,31 @@ class ImportExport /** * @param $obj + * * @return mixed */ public function objectToMultiString($obj) { - if(!\is_array($obj)) { + if (!\is_array($obj)) { return $obj; } $ret_list = []; foreach ($obj as $key => $val) { - if(is_numeric($key) && !\is_array($val)) { + if (is_numeric($key) && !\is_array($val)) { $ret_list[] = $val; continue; } $key = trim($key); - if(!\is_array($val)) { + if (!\is_array($val)) { $val = trim($val); $ret_list[] = "{$key}={$val}"; } else { $q = []; - foreach($val as $subkey => $subval) { - if(is_numeric($subkey)) { + foreach ($val as $subkey => $subval) { + if (is_numeric($subkey)) { $q[] = $subval; } else { $q[] = "{$subkey}={$subval}"; @@ -219,7 +233,7 @@ class ImportExport } $q = implode('&', $q); - if(!empty($q)) { + if (!empty($q)) { $ret_list[] = "{$key}?{$q}"; } else { $ret_list[] = $key; diff --git a/app/Interfaces/Listener.php b/app/Interfaces/Listener.php index 555640aa..e732aac6 100644 --- a/app/Interfaces/Listener.php +++ b/app/Interfaces/Listener.php @@ -4,9 +4,7 @@ namespace App\Interfaces; /** * Class Listener - * @package App\Interfaces */ abstract class Listener { - } diff --git a/app/Interfaces/Metar.php b/app/Interfaces/Metar.php index dc2ec109..1a8fbe6e 100644 --- a/app/Interfaces/Metar.php +++ b/app/Interfaces/Metar.php @@ -7,7 +7,6 @@ use Log; /** * Base class for implementing retrieving METARs - * @package App\Interfaces */ abstract class Metar { @@ -15,20 +14,25 @@ abstract class Metar * Implement retrieving the METAR- Return the string * Needs to be protected, since this shouldn't be * directly called. Call `get_metar($icao)` instead + * * @param $icao + * * @return mixed */ abstract protected function metar($icao): string; /** * @param $icao + * * @return string */ //abstract protected function taf($icao): string; /** * Download the METAR, wrap in caching + * * @param $icao + * * @return string */ public function get_metar($icao): string @@ -43,7 +47,7 @@ abstract class Metar Log::error('Error getting METAR: '.$e->getMessage(), $e->getTrace()); return ''; } catch (\Exception $e) { - Log::error('Error getting METAR: '. $e->getMessage(), $e->getTrace()); + Log::error('Error getting METAR: '.$e->getMessage(), $e->getTrace()); return ''; } }); diff --git a/app/Interfaces/Migration.php b/app/Interfaces/Migration.php index 1e2336f8..d61298d5 100644 --- a/app/Interfaces/Migration.php +++ b/app/Interfaces/Migration.php @@ -7,7 +7,6 @@ use DB; /** * Class Migration - * @package App\Interfaces */ abstract class Migration extends \Illuminate\Database\Migrations\Migration { @@ -16,6 +15,7 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration /** * At a minimum, this function needs to be implemented + * * @return mixed */ abstract public function up(); @@ -25,13 +25,13 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration */ public function down() { - } /** * Dynamically figure out the offset and the start number for a group. * This way we don't need to mess with how to order things * When calling getNextOrderNumber(users) 31, will be returned, then 32, and so on + * * @param $name * @param null $offset * @param int $start_offset @@ -53,12 +53,12 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration $start_offset = $offset + 1; } } else { - # Now find the number to start from + // Now find the number to start from $start_offset = (int) DB::table('settings')->where('group', $name)->max('order'); if ($start_offset === null) { $start_offset = $offset + 1; } else { - ++$start_offset; + $start_offset++; } $offset = $group->offset; @@ -71,7 +71,9 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration /** * Get the next increment number from a group + * * @param $group + * * @return int */ public function getNextOrderNumber($group): int @@ -81,7 +83,7 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration } $idx = $this->counters[$group]; - ++$this->counters[$group]; + $this->counters[$group]++; return $idx; } @@ -114,6 +116,7 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration /** * Update a setting + * * @param $key * @param $value * @param array $attrs @@ -128,6 +131,7 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration /** * Add rows to a table + * * @param $table * @param $rows */ @@ -137,7 +141,7 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration try { DB::table($table)->insert($row); } catch (\Exception $e) { - # setting already exists, just ignore it + // setting already exists, just ignore it if ($e->getCode() === 23000) { continue; } diff --git a/app/Interfaces/Model.php b/app/Interfaces/Model.php index b01b929d..feb48918 100644 --- a/app/Interfaces/Model.php +++ b/app/Interfaces/Model.php @@ -4,9 +4,9 @@ namespace App\Interfaces; /** * Class Model + * * @property mixed $id * @property bool $skip_mutator - * @package App\Interfaces */ abstract class Model extends \Illuminate\Database\Eloquent\Model { @@ -14,6 +14,7 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model /** * For the factories, skip the mutators. Only apply to one instance + * * @var bool */ public $skip_mutator = false; diff --git a/app/Interfaces/Repository.php b/app/Interfaces/Repository.php index c1d265e4..89e5cabf 100644 --- a/app/Interfaces/Repository.php +++ b/app/Interfaces/Repository.php @@ -6,13 +6,13 @@ use Illuminate\Validation\Validator; /** * Class Repository - * @package App\Interfaces */ abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository { /** * @param $id * @param array $columns + * * @return mixed|null */ public function findWithoutFail($id, $columns = ['*']) @@ -20,12 +20,13 @@ abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository try { return $this->find($id, $columns); } catch (\Exception $e) { - return null; + return; } } /** * @param $values + * * @return bool */ public function validate($values) @@ -44,8 +45,10 @@ abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository /** * Return N most recent items, sorted by created_at + * * @param int $count * @param string $sort_by created_at (default) or updated_at + * * @return mixed */ public function recent($count = null, $sort_by = 'created_at') @@ -55,16 +58,18 @@ abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository /** * Find records with a WHERE clause but also sort them + * * @param $where * @param $sort_by * @param $order_by + * * @return $this */ public function whereOrder($where, $sort_by, $order_by = 'asc') { return $this->scopeQuery(function ($query) use ($where, $sort_by, $order_by) { $q = $query->where($where); - # See if there are multi-column sorts + // See if there are multi-column sorts if (\is_array($sort_by)) { foreach ($sort_by as $key => $sort) { $q = $q->orderBy($key, $sort); @@ -79,17 +84,19 @@ abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository /** * Find records where values don't match a list but sort the rest + * * @param string $col * @param array $values * @param string $sort_by * @param string $order_by + * * @return $this */ public function whereNotInOrder($col, $values, $sort_by, $order_by = 'asc') { return $this->scopeQuery(function ($query) use ($col, $values, $sort_by, $order_by) { $q = $query->whereNotIn($col, $values); - # See if there are multi-column sorts + // See if there are multi-column sorts if (\is_array($sort_by)) { foreach ($sort_by as $key => $sort) { $q = $q->orderBy($key, $sort); diff --git a/app/Interfaces/Service.php b/app/Interfaces/Service.php index 2d3a6e76..1e404e76 100644 --- a/app/Interfaces/Service.php +++ b/app/Interfaces/Service.php @@ -4,9 +4,7 @@ namespace App\Interfaces; /** * Class Service - * @package App\Interfaces */ abstract class Service { - } diff --git a/app/Interfaces/Unit.php b/app/Interfaces/Unit.php index 3334643b..3c3da7bf 100644 --- a/app/Interfaces/Unit.php +++ b/app/Interfaces/Unit.php @@ -6,7 +6,7 @@ use ArrayAccess; /** * Class Unit - * @package App\Interfaces + * * @property mixed $instance * @property string $unit * @property array $units @@ -20,12 +20,14 @@ class Unit implements ArrayAccess /** * All of the units of this class + * * @var array */ public $units; /** * Holds an instance of the PhpUnit type + * * @var */ protected $instance; @@ -40,7 +42,9 @@ class Unit implements ArrayAccess /** * Implements ArrayAccess + * * @param $offset + * * @return bool */ public function offsetExists($offset) @@ -50,7 +54,9 @@ class Unit implements ArrayAccess /** * Implements ArrayAccess + * * @param $offset + * * @return mixed */ public function offsetGet($offset) @@ -60,6 +66,7 @@ class Unit implements ArrayAccess /** * Implements ArrayAccess + * * @param $offset * @param $value */ @@ -70,6 +77,7 @@ class Unit implements ArrayAccess /** * Implements ArrayAccess + * * @param $offset */ public function offsetUnset($offset) diff --git a/app/Interfaces/Widget.php b/app/Interfaces/Widget.php index 4d9fe830..58b42570 100644 --- a/app/Interfaces/Widget.php +++ b/app/Interfaces/Widget.php @@ -6,7 +6,6 @@ use Arrilot\Widgets\AbstractWidget; /** * Class Widget - * @package App\Widgets */ abstract class Widget extends AbstractWidget { @@ -14,8 +13,10 @@ abstract class Widget extends AbstractWidget /** * Render the template + * * @param string $template * @param array $vars + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function view(string $template, array $vars = []) diff --git a/app/Listeners/AwardListener.php b/app/Listeners/AwardListener.php index 3052310d..3efc4ae4 100644 --- a/app/Listeners/AwardListener.php +++ b/app/Listeners/AwardListener.php @@ -9,13 +9,14 @@ use App\Models\Award; /** * Look for and run any of the award classes. Don't modify this. * See the documentation on creating awards: + * * @url http://docs.phpvms.net/customizing/awards - * @package App\Listeners */ class AwardListener extends Listener { /** * Call all of the awards + * * @param UserStatsChanged $event */ public function handle(UserStatsChanged $event): void diff --git a/app/Listeners/ExpenseListener.php b/app/Listeners/ExpenseListener.php index 72432a0f..544f83d5 100644 --- a/app/Listeners/ExpenseListener.php +++ b/app/Listeners/ExpenseListener.php @@ -7,22 +7,23 @@ use App\Interfaces\Listener; /** * Class ExpenseListener - * @package App\Listeners */ class ExpenseListener extends Listener { /** * Return a list of additional expenses + * * @param Expenses $event + * * @return mixed */ public function handle(Expenses $event) { $expenses = []; - # This is an example of an expense to return - # You have the pirep on $event->pirep, and any associated data - # The transaction group is how it will show as a line item + // This is an example of an expense to return + // You have the pirep on $event->pirep, and any associated data + // The transaction group is how it will show as a line item /*$expenses[] = new Expense([ 'type' => ExpenseType::FLIGHT, 'amount' => 15000, # $150 diff --git a/app/Listeners/FinanceEvents.php b/app/Listeners/FinanceEvents.php index c357205e..49d24015 100644 --- a/app/Listeners/FinanceEvents.php +++ b/app/Listeners/FinanceEvents.php @@ -11,7 +11,6 @@ use Illuminate\Contracts\Events\Dispatcher; /** * Subscribe for events that we do some financial processing for * This includes when a PIREP is accepted, or rejected - * @package App\Listeners */ class FinanceEvents extends Listener { @@ -19,6 +18,7 @@ class FinanceEvents extends Listener /** * FinanceEvents constructor. + * * @param PirepFinanceService $financeSvc */ public function __construct( @@ -45,7 +45,9 @@ class FinanceEvents extends Listener /** * Kick off the finance events when a PIREP is accepted + * * @param PirepAccepted $event + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException * @throws \Exception @@ -58,7 +60,9 @@ class FinanceEvents extends Listener /** * Delete all finances in the journal for a given PIREP + * * @param PirepRejected $event + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException * @throws \Exception diff --git a/app/Listeners/NotificationEvents.php b/app/Listeners/NotificationEvents.php index 96f910b7..5d2282cc 100644 --- a/app/Listeners/NotificationEvents.php +++ b/app/Listeners/NotificationEvents.php @@ -12,7 +12,6 @@ use Log; /** * Handle sending emails on different events - * @package App\Listeners */ class NotificationEvents extends Listener { @@ -48,6 +47,7 @@ class NotificationEvents extends Listener /** * @param $to * @param $email + * * @return mixed */ protected function sendEmail($to, $email) @@ -62,6 +62,7 @@ class NotificationEvents extends Listener /** * Send an email when the user registered + * * @param UserRegistered $event */ public function onUserRegister(UserRegistered $event): void @@ -75,7 +76,7 @@ class NotificationEvents extends Listener return; } - # First send the admin a notification + // First send the admin a notification $admin_email = setting('general.admin_email'); Log::info('Sending admin notification email to "'.$admin_email.'"'); @@ -84,10 +85,10 @@ class NotificationEvents extends Listener $this->sendEmail($admin_email, $email); } - # Then notify the user + // Then notify the user if ($event->user->state === UserState::ACTIVE) { $email = new \App\Mail\UserRegistered($event->user); - } else if ($event->user->state === UserState::PENDING) { + } elseif ($event->user->state === UserState::PENDING) { $email = new \App\Mail\UserPending($event->user); } @@ -96,6 +97,7 @@ class NotificationEvents extends Listener /** * When a user's state changes, send an email out + * * @param UserStateChanged $event */ public function onUserStateChange(UserStateChanged $event): void @@ -108,11 +110,11 @@ class NotificationEvents extends Listener if ($event->user->state === UserState::ACTIVE) { $email = new \App\Mail\UserRegistered($event->user, 'Your registration has been accepted!'); - } else if ($event->user->state === UserState::REJECTED) { + } elseif ($event->user->state === UserState::REJECTED) { $email = new \App\Mail\UserRejected($event->user); } $this->sendEmail($event->user->email, $email); - } # TODO: Other state transitions + } // TODO: Other state transitions elseif ($event->old_state === UserState::ACTIVE) { Log::info('User state change from active to ??'); } diff --git a/app/Mail/Admin/UserRegistered.php b/app/Mail/Admin/UserRegistered.php index 1a81d8e3..8a5b0cc6 100644 --- a/app/Mail/Admin/UserRegistered.php +++ b/app/Mail/Admin/UserRegistered.php @@ -10,7 +10,8 @@ use Illuminate\Queue\SerializesModels; class UserRegistered extends Mailable { use Queueable, SerializesModels; - public $subject, $user; + public $subject; + public $user; public function __construct(User $user, $subject = null) { diff --git a/app/Mail/NewLoginDetails.php b/app/Mail/NewLoginDetails.php index f0821467..42f4fedb 100644 --- a/app/Mail/NewLoginDetails.php +++ b/app/Mail/NewLoginDetails.php @@ -10,7 +10,9 @@ use Illuminate\Queue\SerializesModels; class NewLoginDetails extends Mailable { use Queueable, SerializesModels; - public $subject, $user, $newpw; + public $subject; + public $user; + public $newpw; public function __construct(User $user, $newpw = null, $subject = null) { diff --git a/app/Mail/UserPending.php b/app/Mail/UserPending.php index 541409be..c0cf765a 100644 --- a/app/Mail/UserPending.php +++ b/app/Mail/UserPending.php @@ -10,7 +10,8 @@ use Illuminate\Queue\SerializesModels; class UserPending extends Mailable { use Queueable, SerializesModels; - public $subject, $user; + public $subject; + public $user; public function __construct(User $user, $subject = null) { diff --git a/app/Mail/UserRegistered.php b/app/Mail/UserRegistered.php index 995e00da..013042ab 100644 --- a/app/Mail/UserRegistered.php +++ b/app/Mail/UserRegistered.php @@ -10,7 +10,8 @@ use Illuminate\Queue\SerializesModels; class UserRegistered extends Mailable { use Queueable, SerializesModels; - public $subject, $user; + public $subject; + public $user; public function __construct(User $user, $subject = null) { diff --git a/app/Mail/UserRejected.php b/app/Mail/UserRejected.php index 6c8a2021..40dc991a 100644 --- a/app/Mail/UserRejected.php +++ b/app/Mail/UserRejected.php @@ -10,7 +10,8 @@ use Illuminate\Queue\SerializesModels; class UserRejected extends Mailable { use Queueable, SerializesModels; - public $subject, $user; + public $subject; + public $user; public function __construct(User $user, $subject = null) { diff --git a/app/Models/Acars.php b/app/Models/Acars.php index 2e53883c..dffba7b7 100644 --- a/app/Models/Acars.php +++ b/app/Models/Acars.php @@ -11,18 +11,19 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName; /** * Class Acars + * * @param string id + * * @property string pirep_id * @property int type * @property string name - * @property double lat - * @property double lon - * @property double altitude + * @property float lat + * @property float lon + * @property float altitude * @property int gs * @property int heading * @property int order * @property int nav_type - * @package App\Models */ class Acars extends Model { @@ -78,15 +79,15 @@ class Acars extends Model 'pirep_id' => 'required', ]; - /** * Return a new Length unit so conversions can be made + * * @return int|Distance */ public function getDistanceAttribute() { if (!array_key_exists('distance', $this->attributes)) { - return null; + return; } try { @@ -105,6 +106,7 @@ class Acars extends Model /** * Set the distance unit, convert to our internal default unit + * * @param $value */ public function setDistanceAttribute($value): void @@ -119,12 +121,13 @@ class Acars extends Model /** * Return a new Fuel unit so conversions can be made + * * @return int|Fuel */ public function getFuelAttribute() { if (!array_key_exists('fuel', $this->attributes)) { - return null; + return; } try { @@ -139,6 +142,7 @@ class Acars extends Model /** * Set the amount of fuel + * * @param $value */ public function setFuelAttribute($value) @@ -155,7 +159,6 @@ class Acars extends Model /** * FKs */ - public function pirep() { return $this->belongsTo(Pirep::class, 'pirep_id'); diff --git a/app/Models/Aircraft.php b/app/Models/Aircraft.php index d00103b8..24071969 100644 --- a/app/Models/Aircraft.php +++ b/app/Models/Aircraft.php @@ -18,7 +18,6 @@ use App\Models\Traits\FilesTrait; * @property Subfleet subfleet * @property int status * @property int state - * @package App\Models */ class Aircraft extends Model { @@ -60,6 +59,7 @@ class Aircraft extends Model /** * See if this aircraft is active + * * @return bool */ public function getActiveAttribute(): bool @@ -69,6 +69,7 @@ class Aircraft extends Model /** * Capitalize the ICAO when set + * * @param $icao */ public function setIcaoAttribute($icao): void @@ -79,7 +80,6 @@ class Aircraft extends Model /** * foreign keys */ - public function airport() { return $this->belongsTo(Airport::class, 'airport_id'); diff --git a/app/Models/Airline.php b/app/Models/Airline.php index 8f0c81c1..47cc0e9e 100644 --- a/app/Models/Airline.php +++ b/app/Models/Airline.php @@ -9,6 +9,7 @@ use App\Models\Traits\JournalTrait; /** * Class Airline + * * @property mixed id * @property string code * @property string icao @@ -17,7 +18,6 @@ use App\Models\Traits\JournalTrait; * @property string logo * @property string country * @property Journal journal - * @package App\Models */ class Airline extends Model { @@ -44,6 +44,7 @@ class Airline extends Model /** * The attributes that should be casted to native types. + * * @var array */ protected $casts = [ @@ -54,6 +55,7 @@ class Airline extends Model /** * Validation rules + * * @var array */ public static $rules = [ @@ -69,14 +71,15 @@ class Airline extends Model */ public function getCodeAttribute() { - if ($this->iata && $this->iata !== '') - return $this->iata; - else - return $this->icao; + if ($this->iata && $this->iata !== '') { + return $this->iata; + } + return $this->icao; } /** * Capitalize the IATA code when set + * * @param $iata */ public function setIataAttribute($iata) @@ -86,6 +89,7 @@ class Airline extends Model /** * Capitalize the ICAO when set + * * @param $icao */ public function setIcaoAttribute($icao): void diff --git a/app/Models/Airport.php b/app/Models/Airport.php index f8b01284..7054a7c7 100644 --- a/app/Models/Airport.php +++ b/app/Models/Airport.php @@ -8,6 +8,7 @@ use App\Models\Traits\FilesTrait; /** * Class Airport + * * @property string id * @property string iata * @property string icao @@ -18,7 +19,6 @@ use App\Models\Traits\FilesTrait; * @property float ground_handling_cost * @property float lat * @property float lon - * @package App\Models */ class Airport extends Model { @@ -91,6 +91,7 @@ class Airport extends Model /** * Return full name like: * KJFK - John F Kennedy + * * @return string */ public function getFullNameAttribute(): string @@ -100,6 +101,7 @@ class Airport extends Model /** * Shorthand for getting the timezone + * * @return string */ public function getTzAttribute(): string @@ -109,6 +111,7 @@ class Airport extends Model /** * Shorthand for setting the timezone + * * @param $value */ public function setTzAttribute($value): void diff --git a/app/Models/Award.php b/app/Models/Award.php index 49600724..4a3dce33 100755 --- a/app/Models/Award.php +++ b/app/Models/Award.php @@ -6,10 +6,10 @@ use App\Interfaces\Model; /** * The Award model + * * @property mixed id * @property mixed ref_model * @property mixed|null ref_model_params - * @package Award\Models */ class Award extends Model { @@ -28,25 +28,27 @@ class Award extends Model 'description' => 'nullable', 'image_url' => 'nullable', 'ref_model' => 'required', - 'ref_model_params' => 'nullable' + 'ref_model_params' => 'nullable', ]; /** * Get the referring object + * * @param Award|null $award * @param User|null $user + * * @return null */ - public function getReference(Award $award = null, User $user = null) + public function getReference(self $award = null, User $user = null) { if (!$this->ref_model) { - return null; + return; } try { return new $this->ref_model($award, $user); } catch (\Exception $e) { - return null; + return; } } } diff --git a/app/Models/Bid.php b/app/Models/Bid.php index 543f7568..3d559d00 100644 --- a/app/Models/Bid.php +++ b/app/Models/Bid.php @@ -4,9 +4,6 @@ namespace App\Models; use App\Interfaces\Model; -/** - * @package App\Models - */ class Bid extends Model { public $table = 'bids'; diff --git a/app/Models/Enums/AcarsType.php b/app/Models/Enums/AcarsType.php index d62375f1..a6e1a4f0 100644 --- a/app/Models/Enums/AcarsType.php +++ b/app/Models/Enums/AcarsType.php @@ -6,11 +6,10 @@ use App\Interfaces\Enum; /** * Class AcarsType - * @package App\Models\Enums */ class AcarsType extends Enum { public const FLIGHT_PATH = 0; - public const ROUTE = 1; - public const LOG = 2; + public const ROUTE = 1; + public const LOG = 2; } diff --git a/app/Models/Enums/ActiveState.php b/app/Models/Enums/ActiveState.php index ac09b249..5af5daf8 100644 --- a/app/Models/Enums/ActiveState.php +++ b/app/Models/Enums/ActiveState.php @@ -6,15 +6,14 @@ use App\Interfaces\Enum; /** * Class ActiveState - * @package App\Models\Enums */ class ActiveState extends Enum { public const INACTIVE = 0; - public const ACTIVE = 1; + public const ACTIVE = 1; public static $labels = [ - ActiveState::ACTIVE => 'common.active', - ActiveState::INACTIVE => 'common.inactive', + self::ACTIVE => 'common.active', + self::INACTIVE => 'common.inactive', ]; } diff --git a/app/Models/Enums/AircraftState.php b/app/Models/Enums/AircraftState.php index 82ec2cc2..f81cfe81 100644 --- a/app/Models/Enums/AircraftState.php +++ b/app/Models/Enums/AircraftState.php @@ -6,7 +6,6 @@ use App\Interfaces\Enum; /** * Class AircraftState - * @package App\Models\Enums */ class AircraftState extends Enum { @@ -15,8 +14,8 @@ class AircraftState extends Enum public const IN_AIR = 2; public static $labels = [ - AircraftState::PARKED => 'On Ground', - AircraftState::IN_USE => 'In Use', - AircraftState::IN_AIR => 'In Air', + self::PARKED => 'On Ground', + self::IN_USE => 'In Use', + self::IN_AIR => 'In Air', ]; } diff --git a/app/Models/Enums/AircraftStatus.php b/app/Models/Enums/AircraftStatus.php index 82f05afe..18de63e2 100644 --- a/app/Models/Enums/AircraftStatus.php +++ b/app/Models/Enums/AircraftStatus.php @@ -6,21 +6,20 @@ use App\Interfaces\Enum; /** * Class AircraftState - * @package App\Models\Enums */ class AircraftStatus extends Enum { - public const ACTIVE = 'A'; - public const STORED = 'S'; - public const RETIRED = 'R'; - public const SCRAPPED = 'C'; + public const ACTIVE = 'A'; + public const STORED = 'S'; + public const RETIRED = 'R'; + public const SCRAPPED = 'C'; public const WRITTEN_OFF = 'W'; public static $labels = [ - AircraftStatus::ACTIVE => 'aircraft.status.active', - AircraftStatus::STORED => 'aircraft.status.stored', - AircraftStatus::RETIRED => 'aircraft.status.retired', - AircraftStatus::SCRAPPED => 'aircraft.status.scrapped', - AircraftStatus::WRITTEN_OFF => 'aircraft.status.written', + self::ACTIVE => 'aircraft.status.active', + self::STORED => 'aircraft.status.stored', + self::RETIRED => 'aircraft.status.retired', + self::SCRAPPED => 'aircraft.status.scrapped', + self::WRITTEN_OFF => 'aircraft.status.written', ]; } diff --git a/app/Models/Enums/AnalyticsDimensions.php b/app/Models/Enums/AnalyticsDimensions.php index fa262943..d654d59a 100644 --- a/app/Models/Enums/AnalyticsDimensions.php +++ b/app/Models/Enums/AnalyticsDimensions.php @@ -6,11 +6,10 @@ use App\Interfaces\Enum; /** * Class AnalyticsDimensions - * @package App\Models\Enums */ class AnalyticsDimensions extends Enum { - public const PHP_VERSION = 1; + public const PHP_VERSION = 1; public const DATABASE_VERSION = 2; - public const PHPVMS_VERSION = 3; + public const PHPVMS_VERSION = 3; } diff --git a/app/Models/Enums/AnalyticsMetrics.php b/app/Models/Enums/AnalyticsMetrics.php index 7a8fc864..d5963e2a 100644 --- a/app/Models/Enums/AnalyticsMetrics.php +++ b/app/Models/Enums/AnalyticsMetrics.php @@ -7,10 +7,9 @@ use App\Interfaces\Enum; /** * Class AnalyticsMetrics * Metrics IDs used in Google Analytics - * @package App\Models\Enums */ class AnalyticsMetrics extends Enum { - # Track the lookup time for airports from vaCentral + // Track the lookup time for airports from vaCentral public const AIRPORT_LOOKUP_TIME = 1; } diff --git a/app/Models/Enums/Days.php b/app/Models/Enums/Days.php index feddc424..5733aaec 100644 --- a/app/Models/Enums/Days.php +++ b/app/Models/Enums/Days.php @@ -7,60 +7,61 @@ use App\Interfaces\Enum; /** * Class Days * Start on Monday - ISO8601 - * @package App\Models\Enums */ class Days extends Enum { - public const MONDAY = 1 << 0; - public const TUESDAY = 1 << 1; + public const MONDAY = 1 << 0; + public const TUESDAY = 1 << 1; public const WEDNESDAY = 1 << 2; - public const THURSDAY = 1 << 3; - public const FRIDAY = 1 << 4; - public const SATURDAY = 1 << 5; - public const SUNDAY = 1 << 6; + public const THURSDAY = 1 << 3; + public const FRIDAY = 1 << 4; + public const SATURDAY = 1 << 5; + public const SUNDAY = 1 << 6; public static $labels = [ - Days::MONDAY => 'common.days.mon', - Days::TUESDAY => 'common.days.tues', - Days::WEDNESDAY => 'common.days.wed', - Days::THURSDAY => 'common.days.thurs', - Days::FRIDAY => 'common.days.fri', - Days::SATURDAY => 'common.days.sat', - Days::SUNDAY => 'common.days.sun', + self::MONDAY => 'common.days.mon', + self::TUESDAY => 'common.days.tues', + self::WEDNESDAY => 'common.days.wed', + self::THURSDAY => 'common.days.thurs', + self::FRIDAY => 'common.days.fri', + self::SATURDAY => 'common.days.sat', + self::SUNDAY => 'common.days.sun', ]; public static $codes = [ - 'M' => Days::MONDAY, - 'T' => Days::TUESDAY, - 'W' => Days::WEDNESDAY, - 'Th' => Days::THURSDAY, - 'F' => Days::FRIDAY, - 'S' => Days::SATURDAY, - 'Su' => Days::SUNDAY, + 'M' => self::MONDAY, + 'T' => self::TUESDAY, + 'W' => self::WEDNESDAY, + 'Th' => self::THURSDAY, + 'F' => self::FRIDAY, + 'S' => self::SATURDAY, + 'Su' => self::SUNDAY, ]; /** * Map the ISO8601 numeric today to day */ public static $isoDayMap = [ - 1 => Days::MONDAY, - 2 => Days::TUESDAY, - 3 => Days::WEDNESDAY, - 4 => Days::THURSDAY, - 5 => Days::FRIDAY, - 6 => Days::SATURDAY, - 7 => Days::SUNDAY, + 1 => self::MONDAY, + 2 => self::TUESDAY, + 3 => self::WEDNESDAY, + 4 => self::THURSDAY, + 5 => self::FRIDAY, + 6 => self::SATURDAY, + 7 => self::SUNDAY, ]; /** * Create the masked value for the days of week + * * @param array $days + * * @return int|mixed */ public static function getDaysMask(array $days) { $mask = 0; - foreach($days as $day) { + foreach ($days as $day) { $mask |= $day; } @@ -69,8 +70,10 @@ class Days extends Enum /** * See if the given mask has a day + * * @param $mask * @param $day + * * @return bool */ public static function in($mask, $day): bool @@ -80,7 +83,9 @@ class Days extends Enum /** * Does the mask contain today? + * * @param $val + * * @return bool */ public static function isToday($val): bool diff --git a/app/Models/Enums/ExpenseType.php b/app/Models/Enums/ExpenseType.php index 6d119d49..396ffcaa 100644 --- a/app/Models/Enums/ExpenseType.php +++ b/app/Models/Enums/ExpenseType.php @@ -6,23 +6,22 @@ use App\Interfaces\Enum; /** * Class ExpenseType - * @package App\Models\Enums */ class ExpenseType extends Enum { - public const FLIGHT = 'F'; - public const DAILY = 'D'; + public const FLIGHT = 'F'; + public const DAILY = 'D'; public const MONTHLY = 'M'; protected static $labels = [ - ExpenseType::FLIGHT => 'expenses.type.flight', - ExpenseType::DAILY => 'expenses.type.daily', - ExpenseType::MONTHLY => 'expenses.type.monthly', + self::FLIGHT => 'expenses.type.flight', + self::DAILY => 'expenses.type.daily', + self::MONTHLY => 'expenses.type.monthly', ]; protected static $codes = [ - ExpenseType::FLIGHT => 'F', - ExpenseType::DAILY =>'D', - ExpenseType::MONTHLY => 'M', + self::FLIGHT => 'F', + self::DAILY => 'D', + self::MONTHLY => 'M', ]; } diff --git a/app/Models/Enums/FlightType.php b/app/Models/Enums/FlightType.php index fe24815f..47681232 100644 --- a/app/Models/Enums/FlightType.php +++ b/app/Models/Enums/FlightType.php @@ -6,41 +6,40 @@ use App\Interfaces\Enum; /** * Class FlightType - * @package App\Models\Enums */ class FlightType extends Enum { - public const SCHED_PAX = 'J'; - public const SCHED_CARGO = 'F'; - public const CHARTER_PAX_ONLY = 'C'; - public const ADDITIONAL_CARGO = 'A'; - public const VIP = 'E'; - public const ADDTL_PAX = 'G'; + public const SCHED_PAX = 'J'; + public const SCHED_CARGO = 'F'; + public const CHARTER_PAX_ONLY = 'C'; + public const ADDITIONAL_CARGO = 'A'; + public const VIP = 'E'; + public const ADDTL_PAX = 'G'; public const CHARTER_CARGO_MAIL = 'H'; - public const AMBULANCE = 'I'; - public const TRAINING = 'K'; - public const MAIL_SERVICE = 'M'; - public const CHARTER_SPECIAL = 'O'; - public const POSITIONING = 'P'; - public const TECHNICAL_TEST = 'T'; - public const MILITARY = 'W'; - public const TECHNICAL_STOP = 'X'; + public const AMBULANCE = 'I'; + public const TRAINING = 'K'; + public const MAIL_SERVICE = 'M'; + public const CHARTER_SPECIAL = 'O'; + public const POSITIONING = 'P'; + public const TECHNICAL_TEST = 'T'; + public const MILITARY = 'W'; + public const TECHNICAL_STOP = 'X'; protected static $labels = [ - FlightType::SCHED_PAX => 'flights.type.pass_scheduled', - FlightType::SCHED_CARGO => 'flights.type.cargo_scheduled', - FlightType::CHARTER_PAX_ONLY => 'flights.type.charter_pass_only', - FlightType::ADDITIONAL_CARGO => 'flights.type.addtl_cargo_mail', - FlightType::VIP => 'flights.type.special_vip', - FlightType::ADDTL_PAX => 'flights.type.pass_addtl', - FlightType::CHARTER_CARGO_MAIL => 'flights.type.charter_cargo', - FlightType::AMBULANCE => 'flights.type.ambulance', - FlightType::TRAINING => 'flights.type.training_flight', - FlightType::MAIL_SERVICE => 'flights.type.mail_service', - FlightType::CHARTER_SPECIAL => 'flights.type.charter_special', - FlightType::POSITIONING => 'flights.type.positioning', - FlightType::TECHNICAL_TEST => 'flights.type.technical_test', - FlightType::MILITARY => 'flights.type.military', - FlightType::TECHNICAL_STOP => 'flights.type.technical_stop', + self::SCHED_PAX => 'flights.type.pass_scheduled', + self::SCHED_CARGO => 'flights.type.cargo_scheduled', + self::CHARTER_PAX_ONLY => 'flights.type.charter_pass_only', + self::ADDITIONAL_CARGO => 'flights.type.addtl_cargo_mail', + self::VIP => 'flights.type.special_vip', + self::ADDTL_PAX => 'flights.type.pass_addtl', + self::CHARTER_CARGO_MAIL => 'flights.type.charter_cargo', + self::AMBULANCE => 'flights.type.ambulance', + self::TRAINING => 'flights.type.training_flight', + self::MAIL_SERVICE => 'flights.type.mail_service', + self::CHARTER_SPECIAL => 'flights.type.charter_special', + self::POSITIONING => 'flights.type.positioning', + self::TECHNICAL_TEST => 'flights.type.technical_test', + self::MILITARY => 'flights.type.military', + self::TECHNICAL_STOP => 'flights.type.technical_stop', ]; } diff --git a/app/Models/Enums/FuelType.php b/app/Models/Enums/FuelType.php index 5a8ac332..bbaf6bba 100644 --- a/app/Models/Enums/FuelType.php +++ b/app/Models/Enums/FuelType.php @@ -6,17 +6,16 @@ use App\Interfaces\Enum; /** * Class FuelType - * @package App\Models\Enums */ class FuelType extends Enum { public const LOW_LEAD = 0; - public const JET_A = 1; - public const MOGAS = 2; + public const JET_A = 1; + public const MOGAS = 2; public static $labels = [ - FuelType::LOW_LEAD => '100LL', - FuelType::JET_A => 'JET A', - FuelType::MOGAS => 'MOGAS', + self::LOW_LEAD => '100LL', + self::JET_A => 'JET A', + self::MOGAS => 'MOGAS', ]; } diff --git a/app/Models/Enums/JournalType.php b/app/Models/Enums/JournalType.php index 71f943eb..61d2151f 100644 --- a/app/Models/Enums/JournalType.php +++ b/app/Models/Enums/JournalType.php @@ -6,10 +6,9 @@ use App\Interfaces\Enum; /** * Class JournalType - * @package App\Models\Enums */ class JournalType extends Enum { public const AIRLINE = 0; - public const USER = 1; + public const USER = 1; } diff --git a/app/Models/Enums/NavaidType.php b/app/Models/Enums/NavaidType.php index b17a3bdd..4cda1c52 100644 --- a/app/Models/Enums/NavaidType.php +++ b/app/Models/Enums/NavaidType.php @@ -8,49 +8,49 @@ use App\Interfaces\Enum; * Class NavaidType * Types based on/compatible with OpenFMC * https://github.com/skiselkov/openfmc/blob/master/airac.h - * @package App\Models\Enums */ class NavaidType extends Enum { - public const VOR = 1 << 0; - public const VOR_DME = 1 << 1; - public const LOC = 1 << 4; - public const LOC_DME = 1 << 5; - public const NDB = 1 << 6; - public const TACAN = 1 << 7; - public const UNKNOWN = 1 << 8; + public const VOR = 1 << 0; + public const VOR_DME = 1 << 1; + public const LOC = 1 << 4; + public const LOC_DME = 1 << 5; + public const NDB = 1 << 6; + public const TACAN = 1 << 7; + public const UNKNOWN = 1 << 8; public const INNER_MARKER = 1 << 9; public const OUTER_MARKER = 1 << 10; - public const FIX = 1 << 11; - public const ANY_VOR = NavaidType::VOR | NavaidType::VOR_DME; - public const ANY_LOC = NavaidType::LOC | NavaidType::LOC_DME; - public const ANY = (NavaidType::UNKNOWN << 1) - 1; + public const FIX = 1 << 11; + public const ANY_VOR = self::VOR | self::VOR_DME; + public const ANY_LOC = self::LOC | self::LOC_DME; + public const ANY = (self::UNKNOWN << 1) - 1; /** * Names and titles + * * @var array */ public static $labels = [ - NavaidType::VOR => 'VOR', - NavaidType::VOR_DME => 'VOR DME', - NavaidType::LOC => 'Localizer', - NavaidType::LOC_DME => 'Localizer DME', - NavaidType::NDB => 'Non-directional Beacon', - NavaidType::TACAN => 'TACAN', - NavaidType::UNKNOWN => 'Unknown', - NavaidType::ANY_VOR => 'VOR', - NavaidType::ANY_LOC => 'Localizer', + self::VOR => 'VOR', + self::VOR_DME => 'VOR DME', + self::LOC => 'Localizer', + self::LOC_DME => 'Localizer DME', + self::NDB => 'Non-directional Beacon', + self::TACAN => 'TACAN', + self::UNKNOWN => 'Unknown', + self::ANY_VOR => 'VOR', + self::ANY_LOC => 'Localizer', ]; public static $icons = [ - NavaidType::VOR => 'VOR', - NavaidType::VOR_DME => 'VOR DME', - NavaidType::LOC => 'Localizer', - NavaidType::LOC_DME => 'Localizer DME', - NavaidType::NDB => 'Non-directional Beacon', - NavaidType::TACAN => 'TACAN', - NavaidType::UNKNOWN => 'Unknown', - NavaidType::ANY_VOR => 'VOR', - NavaidType::ANY_LOC => 'Localizer', + self::VOR => 'VOR', + self::VOR_DME => 'VOR DME', + self::LOC => 'Localizer', + self::LOC_DME => 'Localizer DME', + self::NDB => 'Non-directional Beacon', + self::TACAN => 'TACAN', + self::UNKNOWN => 'Unknown', + self::ANY_VOR => 'VOR', + self::ANY_LOC => 'Localizer', ]; } diff --git a/app/Models/Enums/PirepFieldSource.php b/app/Models/Enums/PirepFieldSource.php index cc7784f8..aec5809a 100644 --- a/app/Models/Enums/PirepFieldSource.php +++ b/app/Models/Enums/PirepFieldSource.php @@ -6,10 +6,9 @@ use App\Interfaces\Enum; /** * Class AcarsType - * @package App\Models\Enums */ class PirepFieldSource extends Enum { public const MANUAL = 0; - public const ACARS = 1; + public const ACARS = 1; } diff --git a/app/Models/Enums/PirepSource.php b/app/Models/Enums/PirepSource.php index 47c61428..eba5835e 100644 --- a/app/Models/Enums/PirepSource.php +++ b/app/Models/Enums/PirepSource.php @@ -6,15 +6,14 @@ use App\Interfaces\Enum; /** * Class PirepSource - * @package App\Models\Enums */ class PirepSource extends Enum { public const MANUAL = 0; - public const ACARS = 1; + public const ACARS = 1; protected static $labels = [ - PirepSource::MANUAL => 'pireps.source_types.manual', - PirepSource::ACARS => 'pireps.source_types.acars', + self::MANUAL => 'pireps.source_types.manual', + self::ACARS => 'pireps.source_types.acars', ]; } diff --git a/app/Models/Enums/PirepState.php b/app/Models/Enums/PirepState.php index 0c89e940..8938da35 100644 --- a/app/Models/Enums/PirepState.php +++ b/app/Models/Enums/PirepState.php @@ -6,25 +6,24 @@ use App\Interfaces\Enum; /** * Class PirepState - * @package App\Models\Enums */ class PirepState extends Enum { - public const REJECTED = -1; + public const REJECTED = -1; public const IN_PROGRESS = 0; // flight is ongoing - public const PENDING = 1; // waiting admin approval - public const ACCEPTED = 2; - public const CANCELLED = 3; - public const DELETED = 4; - public const DRAFT = 5; + public const PENDING = 1; // waiting admin approval + public const ACCEPTED = 2; + public const CANCELLED = 3; + public const DELETED = 4; + public const DRAFT = 5; protected static $labels = [ - PirepState::REJECTED => 'pireps.state.rejected', - PirepState::IN_PROGRESS => 'pireps.state.in_progress', - PirepState::PENDING => 'pireps.state.pending', - PirepState::ACCEPTED => 'pireps.state.accepted', - PirepState::CANCELLED => 'pireps.state.cancelled', - PirepState::DELETED => 'pireps.state.deleted', - PirepState::DRAFT => 'pireps.state.draft', + self::REJECTED => 'pireps.state.rejected', + self::IN_PROGRESS => 'pireps.state.in_progress', + self::PENDING => 'pireps.state.pending', + self::ACCEPTED => 'pireps.state.accepted', + self::CANCELLED => 'pireps.state.cancelled', + self::DELETED => 'pireps.state.deleted', + self::DRAFT => 'pireps.state.draft', ]; } diff --git a/app/Models/Enums/PirepStatus.php b/app/Models/Enums/PirepStatus.php index 290984bd..c9afc1af 100644 --- a/app/Models/Enums/PirepStatus.php +++ b/app/Models/Enums/PirepStatus.php @@ -8,57 +8,56 @@ use App\Interfaces\Enum; * Tied to the ACARS statuses/states. * Corresponds to values from AIDX and ICAO ADREP * https://www.skybrary.aero/index.php/Flight_Phase_Taxonomy - * @package App\Models\Enums */ class PirepStatus extends Enum { - public const INITIATED = 'INI'; - public const SCHEDULED = 'SCH'; - public const BOARDING = 'BST'; - public const RDY_START = 'RDT'; - public const PUSHBACK_TOW = 'PBT'; - public const DEPARTED = 'OFB'; // Off block - public const RDY_DEICE = 'DIR'; - public const STRT_DEICE = 'DIC'; - public const GRND_RTRN = 'GRT'; // Ground return - public const TAXI = 'TXI'; // Taxi - public const TAKEOFF = 'TOF'; - public const INIT_CLIM = 'ICL'; - public const AIRBORNE = 'TKO'; - public const ENROUTE = 'ENR'; - public const DIVERTED = 'DV'; - public const APPROACH = 'TEN'; + public const INITIATED = 'INI'; + public const SCHEDULED = 'SCH'; + public const BOARDING = 'BST'; + public const RDY_START = 'RDT'; + public const PUSHBACK_TOW = 'PBT'; + public const DEPARTED = 'OFB'; // Off block + public const RDY_DEICE = 'DIR'; + public const STRT_DEICE = 'DIC'; + public const GRND_RTRN = 'GRT'; // Ground return + public const TAXI = 'TXI'; // Taxi + public const TAKEOFF = 'TOF'; + public const INIT_CLIM = 'ICL'; + public const AIRBORNE = 'TKO'; + public const ENROUTE = 'ENR'; + public const DIVERTED = 'DV'; + public const APPROACH = 'TEN'; public const APPROACH_ICAO = 'APR'; - public const ON_FINAL = 'FIN'; - public const LANDING = 'LDG'; - public const LANDED = 'LAN'; - public const ARRIVED = 'ONB'; // On block - public const CANCELLED = 'DX'; - public const EMERG_DECENT = 'EMG'; + public const ON_FINAL = 'FIN'; + public const LANDING = 'LDG'; + public const LANDED = 'LAN'; + public const ARRIVED = 'ONB'; // On block + public const CANCELLED = 'DX'; + public const EMERG_DECENT = 'EMG'; protected static $labels = [ - PirepStatus::INITIATED => 'pireps.status.initialized', - PirepStatus::SCHEDULED => 'pireps.status.scheduled', - PirepStatus::BOARDING => 'pireps.status.boarding', - PirepStatus::RDY_START => 'pireps.status.ready_start', - PirepStatus::PUSHBACK_TOW => 'pireps.status.push_tow', - PirepStatus::DEPARTED => 'pireps.status.departed', - PirepStatus::RDY_DEICE => 'pireps.status.ready_deice', - PirepStatus::STRT_DEICE => 'pireps.status.deicing', - PirepStatus::GRND_RTRN => 'pireps.status.ground_ret', - PirepStatus::TAXI => 'pireps.status.taxi', - PirepStatus::TAKEOFF => 'pireps.status.takeoff', - PirepStatus::INIT_CLIM => 'pireps.status.initial_clb', - PirepStatus::AIRBORNE => 'pireps.status.enroute', - PirepStatus::ENROUTE => 'pireps.status.enroute', - PirepStatus::DIVERTED => 'pireps.status.diverted', - PirepStatus::APPROACH => 'pireps.status.approach', - PirepStatus::APPROACH_ICAO => 'pireps.status.approach', - PirepStatus::ON_FINAL => 'pireps.status.final_appr', - PirepStatus::LANDING => 'pireps.status.landing', - PirepStatus::LANDED => 'pireps.status.landed', - PirepStatus::ARRIVED => 'pireps.status.arrived', - PirepStatus::CANCELLED => 'pireps.status.cancelled', - PirepStatus::EMERG_DECENT => 'pireps.status.emerg_decent', + self::INITIATED => 'pireps.status.initialized', + self::SCHEDULED => 'pireps.status.scheduled', + self::BOARDING => 'pireps.status.boarding', + self::RDY_START => 'pireps.status.ready_start', + self::PUSHBACK_TOW => 'pireps.status.push_tow', + self::DEPARTED => 'pireps.status.departed', + self::RDY_DEICE => 'pireps.status.ready_deice', + self::STRT_DEICE => 'pireps.status.deicing', + self::GRND_RTRN => 'pireps.status.ground_ret', + self::TAXI => 'pireps.status.taxi', + self::TAKEOFF => 'pireps.status.takeoff', + self::INIT_CLIM => 'pireps.status.initial_clb', + self::AIRBORNE => 'pireps.status.enroute', + self::ENROUTE => 'pireps.status.enroute', + self::DIVERTED => 'pireps.status.diverted', + self::APPROACH => 'pireps.status.approach', + self::APPROACH_ICAO => 'pireps.status.approach', + self::ON_FINAL => 'pireps.status.final_appr', + self::LANDING => 'pireps.status.landing', + self::LANDED => 'pireps.status.landed', + self::ARRIVED => 'pireps.status.arrived', + self::CANCELLED => 'pireps.status.cancelled', + self::EMERG_DECENT => 'pireps.status.emerg_decent', ]; } diff --git a/app/Models/Enums/UserState.php b/app/Models/Enums/UserState.php index 220191de..104689b7 100644 --- a/app/Models/Enums/UserState.php +++ b/app/Models/Enums/UserState.php @@ -6,21 +6,20 @@ use App\Interfaces\Enum; /** * Class UserState - * @package App\Models\Enums */ class UserState extends Enum { - public const PENDING = 0; - public const ACTIVE = 1; - public const REJECTED = 2; - public const ON_LEAVE = 3; + public const PENDING = 0; + public const ACTIVE = 1; + public const REJECTED = 2; + public const ON_LEAVE = 3; public const SUSPENDED = 4; protected static $labels = [ - UserState::PENDING => 'user.state.pending', - UserState::ACTIVE => 'user.state.active', - UserState::REJECTED => 'user.state.rejected', - UserState::ON_LEAVE => 'user.state.on_leave', - UserState::SUSPENDED => 'user.state.suspended', + self::PENDING => 'user.state.pending', + self::ACTIVE => 'user.state.active', + self::REJECTED => 'user.state.rejected', + self::ON_LEAVE => 'user.state.on_leave', + self::SUSPENDED => 'user.state.suspended', ]; } diff --git a/app/Models/Expense.php b/app/Models/Expense.php index e282a42e..501c9388 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -1,17 +1,18 @@ belongsTo(Airline::class, 'airline_id'); diff --git a/app/Models/Fare.php b/app/Models/Fare.php index ae9baf03..1e2c90c8 100644 --- a/app/Models/Fare.php +++ b/app/Models/Fare.php @@ -1,16 +1,17 @@ belongsToMany(Subfleet::class, 'subfleet_fare') diff --git a/app/Models/File.php b/app/Models/File.php index 210d2e11..dcdd5f38 100644 --- a/app/Models/File.php +++ b/app/Models/File.php @@ -2,7 +2,6 @@ namespace App\Models; - use App\Interfaces\Model; use App\Models\Traits\HashIdTrait; use App\Models\Traits\ReferenceTrait; @@ -13,11 +12,10 @@ use Illuminate\Support\Facades\Storage; * @property string $description * @property string $disk * @property string $path - * @property boolean $public + * @property bool $public * @property int $download_count * @property string $url * @property string $filename - * @package App\Models */ class File extends Model { @@ -42,13 +40,14 @@ class File extends Model ]; public static $rules = [ - 'name' => 'required', + 'name' => 'required', ]; private $pathinfo; /** * Return the file extension + * * @return string */ public function getExtensionAttribute(): string @@ -62,6 +61,7 @@ class File extends Model /** * Get just the filename + * * @return string */ public function getFilenameAttribute() :string @@ -75,6 +75,7 @@ class File extends Model /** * Get the full URL to this attribute + * * @return string */ public function getUrlAttribute(): string diff --git a/app/Models/Flight.php b/app/Models/Flight.php index 00eb92a5..f5e65d34 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -15,7 +15,7 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName; * @property string id * @property mixed ident * @property Airline airline - * @property integer airline_id + * @property int airline_id * @property mixed flight_number * @property mixed route_code * @property int route_leg @@ -23,7 +23,7 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName; * @property Collection field_values * @property Collection fares * @property Collection subfleets - * @property integer days + * @property int days * @property Airport dep_airport * @property Airport arr_airport * @property Airport alt_airport @@ -42,7 +42,8 @@ class Flight extends Model public $incrementing = false; /** The form wants this */ - public $hours, $minutes; + public $hours; + public $minutes; protected $fillable = [ 'id', @@ -96,13 +97,15 @@ class Flight extends Model /** * Return all of the flights on any given day(s) of the week * Search using bitmasks + * * @param Days[] $days List of the enumerated values + * * @return Flight */ public static function findByDays(array $days) { - $flights = Flight::where('active', true); - foreach($days as $day) { + $flights = self::where('active', true); + foreach ($days as $day) { $flights = $flights->where('days', '&', $day); } @@ -130,12 +133,13 @@ class Flight extends Model /** * Return a new Length unit so conversions can be made + * * @return int|Distance */ public function getDistanceAttribute() { if (!array_key_exists('distance', $this->attributes)) { - return null; + return; } try { @@ -151,6 +155,7 @@ class Flight extends Model /** * Set the distance unit, convert to our internal default unit + * * @param $value */ public function setDistanceAttribute($value): void @@ -166,6 +171,7 @@ class Flight extends Model /** * @param $day + * * @return bool */ public function on_day($day): bool @@ -175,13 +181,15 @@ class Flight extends Model /** * Return a custom field value + * * @param $field_name + * * @return string */ public function field($field_name): string { $field = $this->field_values->where('name', $field_name)->first(); - if($field) { + if ($field) { return $field['value']; } @@ -191,6 +199,7 @@ class Flight extends Model /** * Set the days parameter. If an array is passed, it's * AND'd together to create the mask value + * * @param array|int $val */ public function setDaysAttribute($val): void @@ -205,7 +214,6 @@ class Flight extends Model /** * Relationship */ - public function airline() { return $this->belongsTo(Airline::class, 'airline_id'); diff --git a/app/Models/FlightField.php b/app/Models/FlightField.php index daea8cfc..92af3d0e 100644 --- a/app/Models/FlightField.php +++ b/app/Models/FlightField.php @@ -6,9 +6,9 @@ use App\Interfaces\Model; /** * Class FlightField + * * @property string name * @property string slug - * @package App\Models */ class FlightField extends Model { @@ -31,6 +31,7 @@ class FlightField extends Model /** * When setting the name attribute, also set the slug + * * @param $name */ public function setNameAttribute($name): void diff --git a/app/Models/FlightFieldValue.php b/app/Models/FlightFieldValue.php index 48c38d17..13a0ad78 100644 --- a/app/Models/FlightFieldValue.php +++ b/app/Models/FlightFieldValue.php @@ -6,10 +6,10 @@ use App\Interfaces\Model; /** * Class FlightFieldValue + * * @property string flight_id * @property string name * @property string value - * @package App\Models */ class FlightFieldValue extends Model { @@ -36,7 +36,6 @@ class FlightFieldValue extends Model /** * Relationships */ - public function flight() { return $this->belongsTo(Flight::class, 'flight_id'); diff --git a/app/Models/GeoJson.php b/app/Models/GeoJson.php index 3ca051df..2747567b 100644 --- a/app/Models/GeoJson.php +++ b/app/Models/GeoJson.php @@ -10,7 +10,6 @@ use GeoJson\Geometry\Point; /** * Return different points/features in GeoJSON format * https://tools.ietf.org/html/rfc7946 - * @package App\Models */ class GeoJson { @@ -37,16 +36,17 @@ class GeoJson $point = [$lon, $lat]; $this->line_coords[] = [$lon, $lat]; - if(array_key_exists('alt', $attrs)) { + if (array_key_exists('alt', $attrs)) { $point[] = $attrs['alt']; } $this->point_coords[] = new Feature(new Point($point), $attrs); - ++$this->counter; + $this->counter++; } /** * Get the FeatureCollection for the line + * * @return FeatureCollection */ public function getLine(): FeatureCollection @@ -56,12 +56,13 @@ class GeoJson } return new FeatureCollection([ - new Feature(new LineString($this->line_coords)) + new Feature(new LineString($this->line_coords)), ]); } /** * Get the feature collection of all the points + * * @return FeatureCollection */ public function getPoints(): FeatureCollection diff --git a/app/Models/Journal.php b/app/Models/Journal.php index 238e8867..8672dcc9 100644 --- a/app/Models/Journal.php +++ b/app/Models/Journal.php @@ -12,6 +12,7 @@ use Carbon\Carbon; /** * Class Journal + * * @property mixed id * @property Money $balance * @property string $currency @@ -38,7 +39,7 @@ class Journal extends Model protected $dates = [ 'created_at', 'deleted_at', - 'updated_at' + 'updated_at', ]; /** @@ -51,6 +52,7 @@ class Journal extends Model /** * Relationship + * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function ledger() @@ -60,6 +62,7 @@ class Journal extends Model /** * Relationship + * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function transactions() @@ -77,6 +80,7 @@ class Journal extends Model /** * @param Ledger $ledger + * * @return Journal */ public function assignToLedger(Ledger $ledger) @@ -87,7 +91,6 @@ class Journal extends Model } /** - * * @throws \UnexpectedValueException * @throws \InvalidArgumentException */ @@ -99,9 +102,11 @@ class Journal extends Model /** * @param $value - * @return Money + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException + * + * @return Money */ public function getBalanceAttribute($value): Money { @@ -110,6 +115,7 @@ class Journal extends Model /** * @param $value + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException */ @@ -124,6 +130,7 @@ class Journal extends Model /** * @param Journal $object + * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function transactionsReferencingObjectQuery($object) @@ -136,10 +143,13 @@ class Journal extends Model /** * Get the credit only balance of the journal based on a given date. + * * @param Carbon $date - * @return Money + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException + * + * @return Money */ public function getCreditBalanceOn(Carbon $date) { @@ -152,10 +162,13 @@ class Journal extends Model /** * Get the balance of the journal based on a given date. + * * @param Carbon $date - * @return Money + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException + * + * @return Money */ public function getBalanceOn(Carbon $date) { @@ -165,9 +178,11 @@ class Journal extends Model /** * Get the balance of the journal as of right now, excluding future transactions. - * @return Money + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException + * + * @return Money */ public function getCurrentBalance() { @@ -176,9 +191,11 @@ class Journal extends Model /** * Get the balance of the journal. This "could" include future dates. - * @return Money + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException + * + * @return Money */ public function getBalance() { diff --git a/app/Models/JournalTransaction.php b/app/Models/JournalTransaction.php index 4d4105ab..21aa51e0 100644 --- a/app/Models/JournalTransaction.php +++ b/app/Models/JournalTransaction.php @@ -15,10 +15,10 @@ use App\Models\Traits\ReferenceTrait; * @property string memo * @property string transaction_group * @property string post_date - * @property integer credit - * @property integer debit + * @property int credit + * @property int debit * @property string ref_model - * @property integer ref_model_id + * @property int ref_model_id * @property Journal journal */ class JournalTransaction extends Model @@ -39,7 +39,7 @@ class JournalTransaction extends Model 'tags', 'ref_model', 'ref_model_id', - 'post_date' + 'post_date', ]; protected $casts = [ diff --git a/app/Models/Ledger.php b/app/Models/Ledger.php index 843dcd7d..cf175a0b 100644 --- a/app/Models/Ledger.php +++ b/app/Models/Ledger.php @@ -12,7 +12,7 @@ use Carbon\Carbon; /** * Class Journal - * @package Scottlaurent\Accounting + * * @property Money $balance * @property string $currency * @property Carbon $updated_at @@ -23,9 +23,6 @@ class Ledger extends Model { public $table = 'ledgers'; - /** - * - */ public function journals() { return $this->hasMany(Journal::class); @@ -40,7 +37,6 @@ class Ledger extends Model } /** - * * @throws \UnexpectedValueException * @throws \InvalidArgumentException */ @@ -56,7 +52,6 @@ class Ledger extends Model } /** - * * @throws \UnexpectedValueException * @throws \InvalidArgumentException */ diff --git a/app/Models/Navdata.php b/app/Models/Navdata.php index a2dff0d0..92a0dc52 100644 --- a/app/Models/Navdata.php +++ b/app/Models/Navdata.php @@ -6,7 +6,6 @@ use App\Interfaces\Model; /** * Class Navdata - * @package App\Models */ class Navdata extends Model { @@ -33,6 +32,7 @@ class Navdata extends Model /** * Make sure the ID is in all caps + * * @param $id */ public function setIdAttribute($id): void diff --git a/app/Models/News.php b/app/Models/News.php index 75a25c6e..6c0957a4 100644 --- a/app/Models/News.php +++ b/app/Models/News.php @@ -6,7 +6,6 @@ use App\Interfaces\Model; /** * Class News - * @package App\Models */ class News extends Model { @@ -26,7 +25,6 @@ class News extends Model /** * FOREIGN KEYS */ - public function user() { return $this->belongsTo(User::class, 'user_id'); diff --git a/app/Models/Observers/AircraftObserver.php b/app/Models/Observers/AircraftObserver.php index 2d6b7ee6..05b3138e 100644 --- a/app/Models/Observers/AircraftObserver.php +++ b/app/Models/Observers/AircraftObserver.php @@ -7,7 +7,6 @@ use App\Support\ICAO; /** * Class AircraftObserver - * @package App\Models\Observers */ class AircraftObserver { diff --git a/app/Models/Observers/AirportObserver.php b/app/Models/Observers/AirportObserver.php index 14fc789e..3dd3af3b 100644 --- a/app/Models/Observers/AirportObserver.php +++ b/app/Models/Observers/AirportObserver.php @@ -6,7 +6,6 @@ use App\Models\Airport; /** * Make sure that the fields are properly capitalized - * @package App\Models\Observers */ class AirportObserver { diff --git a/app/Models/Observers/JournalObserver.php b/app/Models/Observers/JournalObserver.php index 56364820..f65d76cb 100644 --- a/app/Models/Observers/JournalObserver.php +++ b/app/Models/Observers/JournalObserver.php @@ -6,12 +6,12 @@ use App\Models\Journal; /** * Class JournalObserver - * @package App\Models\Observers */ class JournalObserver { /** * @param Journal $journal + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException */ diff --git a/app/Models/Observers/JournalTransactionObserver.php b/app/Models/Observers/JournalTransactionObserver.php index f7fe785e..9806ae5c 100644 --- a/app/Models/Observers/JournalTransactionObserver.php +++ b/app/Models/Observers/JournalTransactionObserver.php @@ -6,12 +6,12 @@ use App\Models\JournalTransaction; /** * Class JournalTransactionObserver - * @package App\Models\Observers */ class JournalTransactionObserver { /** * Set the ID to a UUID + * * @param JournalTransaction $transaction */ public function creating(JournalTransaction $transaction): void @@ -23,6 +23,7 @@ class JournalTransactionObserver /** * After transaction is saved, adjust the journal balance + * * @param JournalTransaction $transaction */ public function saved(JournalTransaction $transaction): void @@ -43,6 +44,7 @@ class JournalTransactionObserver /** * After transaction is deleted, adjust the balance on the journal + * * @param JournalTransaction $transaction */ public function deleted(JournalTransaction $transaction): void diff --git a/app/Models/Observers/SettingObserver.php b/app/Models/Observers/SettingObserver.php index e1eb293e..015a405a 100644 --- a/app/Models/Observers/SettingObserver.php +++ b/app/Models/Observers/SettingObserver.php @@ -6,7 +6,6 @@ use App\Models\Setting; /** * Class SettingObserver - * @package App\Models\Observers */ class SettingObserver { diff --git a/app/Models/Observers/Sluggable.php b/app/Models/Observers/Sluggable.php index 079a0f7d..e0415c7d 100644 --- a/app/Models/Observers/Sluggable.php +++ b/app/Models/Observers/Sluggable.php @@ -4,7 +4,6 @@ namespace App\Models\Observers; /** * Create a slug from a name - * @package App\Models\Observers */ class Sluggable { diff --git a/app/Models/Observers/SubfleetObserver.php b/app/Models/Observers/SubfleetObserver.php index 1d92bb3b..3f17de45 100644 --- a/app/Models/Observers/SubfleetObserver.php +++ b/app/Models/Observers/SubfleetObserver.php @@ -6,7 +6,6 @@ use App\Models\Subfleet; /** * Class SubfleetObserver - * @package App\Models\Observers */ class SubfleetObserver { diff --git a/app/Models/Pirep.php b/app/Models/Pirep.php index 83663e7c..e908169b 100644 --- a/app/Models/Pirep.php +++ b/app/Models/Pirep.php @@ -16,13 +16,14 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName; /** * Class Pirep + * * @property string id * @property string flight_number * @property string route_code * @property string route_leg - * @property integer airline_id - * @property integer user_id - * @property integer aircraft_id + * @property int airline_id + * @property int user_id + * @property int aircraft_id * @property Aircraft aircraft * @property Airline airline * @property Airport arr_airport @@ -31,13 +32,13 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName; * @property string dpt_airport_id * @property Carbon block_off_time * @property Carbon block_on_time - * @property integer block_time - * @property integer flight_time In minutes - * @property integer planned_flight_time - * @property double distance - * @property double planned_distance + * @property int block_time + * @property int flight_time In minutes + * @property int planned_flight_time + * @property float distance + * @property float planned_distance * @property string route - * @property integer score + * @property int score * @property User user * @property Flight|null flight * @property Collection fields @@ -49,7 +50,6 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName; * @property bool read_only * @property Acars position * @property Acars[] acars - * @package App\Models */ class Pirep extends Model { @@ -59,7 +59,8 @@ class Pirep extends Model public $incrementing = false; /** The form wants this */ - public $hours, $minutes; + public $hours; + public $minutes; protected $fillable = [ 'id', @@ -137,11 +138,12 @@ class Pirep extends Model /** * Get the flight ident, e.,g JBU1900 + * * @return string */ public function getIdentAttribute(): string { - #$flight_id = $this->airline->code; + //$flight_id = $this->airline->code; $flight_id = $this->flight_number; if (filled($this->route_code)) { @@ -157,6 +159,7 @@ class Pirep extends Model /** * Return the block off time in carbon format + * * @return Carbon */ public function getBlockOffTimeAttribute() @@ -164,12 +167,11 @@ class Pirep extends Model if (array_key_exists('block_off_time', $this->attributes)) { return new Carbon($this->attributes['block_off_time']); } - - return null; } /** * Return the block on time + * * @return Carbon */ public function getBlockOnTimeAttribute() @@ -177,12 +179,11 @@ class Pirep extends Model if (array_key_exists('block_on_time', $this->attributes)) { return new Carbon($this->attributes['block_on_time']); } - - return null; } /** * Return the block on time + * * @return Carbon */ public function getSubmittedAtAttribute() @@ -190,18 +191,17 @@ class Pirep extends Model if (array_key_exists('submitted_at', $this->attributes)) { return new Carbon($this->attributes['submitted_at']); } - - return null; } /** * Return a new Length unit so conversions can be made + * * @return int|Distance */ public function getDistanceAttribute() { if (!array_key_exists('distance', $this->attributes)) { - return null; + return; } try { @@ -220,6 +220,7 @@ class Pirep extends Model /** * Set the distance unit, convert to our internal default unit + * * @param $value */ public function setDistanceAttribute($value): void @@ -242,12 +243,13 @@ class Pirep extends Model /** * Return a new Fuel unit so conversions can be made + * * @return int|Fuel */ public function getFuelUsedAttribute() { if (!array_key_exists('fuel_used', $this->attributes)) { - return null; + return; } try { @@ -263,12 +265,13 @@ class Pirep extends Model /** * Return the planned_distance in a converter class + * * @return int|Distance */ public function getPlannedDistanceAttribute() { if (!array_key_exists('planned_distance', $this->attributes)) { - return null; + return; } try { @@ -291,11 +294,11 @@ class Pirep extends Model public function getProgressPercentAttribute() { $upper_bound = $this->distance['nmi']; - if($this->planned_distance) { + if ($this->planned_distance) { $upper_bound = $this->planned_distance['nmi']; } - if(!$upper_bound) { + if (!$upper_bound) { $upper_bound = 1; } @@ -311,16 +314,16 @@ class Pirep extends Model $custom_fields = PirepField::all(); $field_values = PirepFieldValue::where('pirep_id', $this->id)->get(); - # Merge the field values into $fields - foreach($custom_fields as $field) { + // Merge the field values into $fields + foreach ($custom_fields as $field) { $has_value = $field_values->firstWhere('slug', $field->slug); - if(!$has_value) { + if (!$has_value) { $field_values->push(new PirepFieldValue([ 'pirep_id' => $this->id, - 'name' => $field->name, - 'slug' => $field->slug, - 'value' => '', - 'source' => PirepFieldSource::MANUAL + 'name' => $field->name, + 'slug' => $field->slug, + 'value' => '', + 'source' => PirepFieldSource::MANUAL, ])); } } @@ -330,6 +333,7 @@ class Pirep extends Model /** * Look up the flight, based on the PIREP flight info + * * @return Flight|null */ public function getFlightAttribute(): ?Flight @@ -353,6 +357,7 @@ class Pirep extends Model /** * Set the amount of fuel used + * * @param $value */ public function setFuelUsedAttribute($value) @@ -368,6 +373,7 @@ class Pirep extends Model /** * Set the distance unit, convert to our internal default unit + * * @param $value */ public function setPlannedDistanceAttribute($value) @@ -383,6 +389,7 @@ class Pirep extends Model /** * Do some cleanup on the route + * * @param $route */ public function setRouteAttribute($route): void @@ -401,16 +408,19 @@ class Pirep extends Model /** * Check if this PIREP is allowed to be updated + * * @return bool */ public function allowedUpdates(): bool { - return ! $this->getReadOnlyAttribute(); + return !$this->getReadOnlyAttribute(); } /** * Return a custom field value + * * @param $field_name + * * @return string */ public function field($field_name): string @@ -426,7 +436,6 @@ class Pirep extends Model /** * Foreign Keys */ - public function acars() { return $this->hasMany(Acars::class, 'pirep_id') diff --git a/app/Models/PirepComment.php b/app/Models/PirepComment.php index 224bfd54..16e890fc 100644 --- a/app/Models/PirepComment.php +++ b/app/Models/PirepComment.php @@ -9,7 +9,6 @@ use App\Interfaces\Model; * * @property string pirep_id * @property int user_id - * @package App\Models */ class PirepComment extends Model { diff --git a/app/Models/PirepFare.php b/app/Models/PirepFare.php index 808e807e..7ada428f 100644 --- a/app/Models/PirepFare.php +++ b/app/Models/PirepFare.php @@ -6,7 +6,6 @@ use App\Interfaces\Model; /** * Class PirepFare - * @package App\Models */ class PirepFare extends Model { @@ -30,7 +29,6 @@ class PirepFare extends Model /** * Relationships */ - public function fare() { return $this->belongsTo(Fare::class, 'fare_id'); diff --git a/app/Models/PirepField.php b/app/Models/PirepField.php index e0d5a9c1..957447b3 100644 --- a/app/Models/PirepField.php +++ b/app/Models/PirepField.php @@ -6,9 +6,9 @@ use App\Interfaces\Model; /** * Class PirepField + * * @property string name * @property string slug - * @package App\Models */ class PirepField extends Model { @@ -31,6 +31,7 @@ class PirepField extends Model /** * When setting the name attribute, also set the slug + * * @param $name */ public function setNameAttribute($name): void diff --git a/app/Models/PirepFieldValue.php b/app/Models/PirepFieldValue.php index 02552058..4ebcb2f1 100644 --- a/app/Models/PirepFieldValue.php +++ b/app/Models/PirepFieldValue.php @@ -7,7 +7,6 @@ use App\Models\Enums\PirepFieldSource; /** * Class PirepFieldValue - * @package App\Models */ class PirepFieldValue extends Model { @@ -31,6 +30,7 @@ class PirepFieldValue extends Model /** * If it was filled in from ACARS, then it's read only + * * @return bool */ public function getReadOnlyAttribute() @@ -50,7 +50,6 @@ class PirepFieldValue extends Model /** * Foreign Keys */ - public function pirep() { return $this->belongsTo(Pirep::class, 'pirep_id'); diff --git a/app/Models/Rank.php b/app/Models/Rank.php index 28718c80..7be73c94 100644 --- a/app/Models/Rank.php +++ b/app/Models/Rank.php @@ -6,10 +6,10 @@ use App\Interfaces\Model; /** * Class Rank + * * @property int hours * @property float manual_base_pay_rate * @property float acars_base_pay_rate - * @package App\Models */ class Rank extends Model { diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 98259ece..87cc1273 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -6,6 +6,7 @@ use App\Interfaces\Model; /** * Class Setting + * * @property string id * @property string name * @property string key @@ -14,7 +15,6 @@ use App\Interfaces\Model; * @property string type * @property string options * @property string description - * @package App\Models */ class Setting extends Model { @@ -39,6 +39,7 @@ class Setting extends Model /** * @param $key + * * @return mixed */ public static function formatKey($key) @@ -48,6 +49,7 @@ class Setting extends Model /** * Force formatting the key + * * @param $id */ public function setIdAttribute($id): void @@ -58,6 +60,7 @@ class Setting extends Model /** * Set the key to lowercase + * * @param $key */ public function setKeyAttribute($key): void diff --git a/app/Models/Subfleet.php b/app/Models/Subfleet.php index 3f0b280f..6e743ea2 100644 --- a/app/Models/Subfleet.php +++ b/app/Models/Subfleet.php @@ -8,6 +8,7 @@ use App\Models\Traits\ExpensableTrait; /** * Class Subfleet + * * @property int id * @property string type * @property string name @@ -16,7 +17,6 @@ use App\Models\Traits\ExpensableTrait; * @property float cost_block_hour * @property float cost_delay_minute * @property Airline airline - * @package App\Models */ class Subfleet extends Model { @@ -59,14 +59,13 @@ class Subfleet extends Model */ public function setTypeAttribute($type) { - $type = str_replace([' ', ','], array('-', ''), $type); + $type = str_replace([' ', ','], ['-', ''], $type); $this->attributes['type'] = $type; } /** * Relationships */ - public function aircraft() { return $this->hasMany(Aircraft::class, 'subfleet_id') diff --git a/app/Models/Traits/ExpensableTrait.php b/app/Models/Traits/ExpensableTrait.php index 2abee8e7..c27d0740 100644 --- a/app/Models/Traits/ExpensableTrait.php +++ b/app/Models/Traits/ExpensableTrait.php @@ -12,13 +12,14 @@ trait ExpensableTrait /** * Morph to Expenses. + * * @return mixed */ public function expenses() { return $this->morphMany( Expense::class, - 'expenses', # overridden by the next two anyway + 'expenses', // overridden by the next two anyway 'ref_model', 'ref_model_id' ); diff --git a/app/Models/Traits/FilesTrait.php b/app/Models/Traits/FilesTrait.php index 8154d831..a7db1712 100644 --- a/app/Models/Traits/FilesTrait.php +++ b/app/Models/Traits/FilesTrait.php @@ -8,13 +8,14 @@ trait FilesTrait { /** * Morph to type of File + * * @return mixed */ public function files() { return $this->morphMany( File::class, - 'files', # overridden by the next two anyway + 'files', // overridden by the next two anyway 'ref_model', 'ref_model_id' ); diff --git a/app/Models/Traits/HashIdTrait.php b/app/Models/Traits/HashIdTrait.php index 5e898289..c90022d5 100644 --- a/app/Models/Traits/HashIdTrait.php +++ b/app/Models/Traits/HashIdTrait.php @@ -8,8 +8,9 @@ use Hashids\Hashids; trait HashIdTrait { /** - * @return string * @throws \Hashids\HashidsException + * + * @return string */ final protected static function createNewHashId(): string { @@ -20,6 +21,7 @@ trait HashIdTrait /** * Register callbacks + * * @throws \Hashids\HashidsException */ final protected static function bootHashIdTrait(): void diff --git a/app/Models/Traits/JournalTrait.php b/app/Models/Traits/JournalTrait.php index 5fbf7b7d..46aedad6 100644 --- a/app/Models/Traits/JournalTrait.php +++ b/app/Models/Traits/JournalTrait.php @@ -30,8 +30,10 @@ trait JournalTrait * Initialize a journal for a given model object * * @param string $currency_code - * @return Journal + * * @throws \Exception + * + * @return Journal */ public function initJournal($currency_code = 'USD') { diff --git a/app/Models/Traits/ReferenceTrait.php b/app/Models/Traits/ReferenceTrait.php index f36349d7..5867d0be 100644 --- a/app/Models/Traits/ReferenceTrait.php +++ b/app/Models/Traits/ReferenceTrait.php @@ -4,14 +4,15 @@ namespace App\Models\Traits; /** * Trait ReferenceTrait + * * @property \App\Interfaces\Model $ref_model * @property mixed $ref_model_id - * @package App\Models\Traits */ trait ReferenceTrait { /** * @param \App\Interfaces\Model $object + * * @return self */ public function referencesObject($object) @@ -25,12 +26,13 @@ trait ReferenceTrait /** * Return an instance of the object or null + * * @return \App\Interfaces\Model|null */ public function getReferencedObject() { if (!$this->ref_model || !$this->ref_model_id) { - return null; + return; } if ($this->ref_model === __CLASS__) { @@ -38,11 +40,11 @@ trait ReferenceTrait } try { - $klass = new $this->ref_model; + $klass = new $this->ref_model(); $obj = $klass->find($this->ref_model_id); return $obj; } catch (\Exception $e) { - return null; + return; } } } diff --git a/app/Models/User.php b/app/Models/User.php index 4db60fa2..fcace333 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -10,7 +10,7 @@ use Illuminate\Notifications\Notifiable; use Laratrust\Traits\LaratrustUserTrait; /** - * @property integer id + * @property int id * @property string name * @property string email * @property string password @@ -111,6 +111,7 @@ class User extends Authenticatable /** * Shorthand for getting the timezone + * * @return string */ public function getTzAttribute(): string @@ -120,6 +121,7 @@ class User extends Authenticatable /** * Shorthand for setting the timezone + * * @param $value */ public function setTzAttribute($value) @@ -128,21 +130,22 @@ class User extends Authenticatable } /** - * Return a File model - */ + * Return a File model + */ public function getAvatarAttribute() { if (!$this->attributes['avatar']) { - return null; + return; } return new File([ - 'path' => $this->attributes['avatar'] + 'path' => $this->attributes['avatar'], ]); } /** * @param mixed $size Size of the gravatar, in pixels + * * @return string */ public function gravatar($size = null) @@ -162,7 +165,6 @@ class User extends Authenticatable /** * Foreign Keys */ - public function airline() { return $this->belongsTo(Airline::class, 'airline_id'); @@ -198,6 +200,7 @@ class User extends Authenticatable /** * The bid rows + * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function bids() diff --git a/app/Models/UserAward.php b/app/Models/UserAward.php index 61c367ac..f9d75bf6 100644 --- a/app/Models/UserAward.php +++ b/app/Models/UserAward.php @@ -6,7 +6,6 @@ use App\Interfaces\Model; /** * Class UserAward - * @package App\Models */ class UserAward extends Model { @@ -14,7 +13,7 @@ class UserAward extends Model protected $fillable = [ 'user_id', - 'award_id' + 'award_id', ]; /** diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 7bbe4a22..165f6ad3 100755 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -12,8 +12,8 @@ use App\Models\Observers\AircraftObserver; use App\Models\Observers\AirportObserver; use App\Models\Observers\JournalObserver; use App\Models\Observers\JournalTransactionObserver; -use App\Models\Observers\Sluggable; use App\Models\Observers\SettingObserver; +use App\Models\Observers\Sluggable; use App\Models\Observers\SubfleetObserver; use App\Models\PirepField; use App\Models\PirepFieldValue; @@ -60,10 +60,10 @@ class AppServiceProvider extends ServiceProvider */ public function register(): void { - # Only dev environment stuff + // Only dev environment stuff if ($this->app->environment() === 'dev') { - # Only load the IDE helper if it's included. This lets use distribute the - # package without any dev dependencies + // Only load the IDE helper if it's included. This lets use distribute the + // package without any dev dependencies if (class_exists(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class)) { $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class); } diff --git a/app/Providers/CronServiceProvider.php b/app/Providers/CronServiceProvider.php index 5e0ac041..984a7afb 100644 --- a/app/Providers/CronServiceProvider.php +++ b/app/Providers/CronServiceProvider.php @@ -2,20 +2,19 @@ namespace App\Providers; +use App\Cron\Nightly\ApplyExpenses; +use App\Cron\Nightly\PilotLeave; +use App\Cron\Nightly\RecalculateBalances; use App\Cron\Nightly\RecalculateStats; use App\Cron\Nightly\SetActiveFlights; use App\Events\CronHourly; use App\Events\CronMonthly; use App\Events\CronNightly; use App\Events\CronWeekly; -use App\Cron\Nightly\ApplyExpenses; -use App\Cron\Nightly\PilotLeave; -use App\Cron\Nightly\RecalculateBalances; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; /** * All of the hooks for the cron jobs - * @package App\Providers */ class CronServiceProvider extends ServiceProvider { @@ -32,11 +31,11 @@ class CronServiceProvider extends ServiceProvider ], CronMonthly::class => [ - \App\Cron\Monthly\ApplyExpenses::class + \App\Cron\Monthly\ApplyExpenses::class, ], CronHourly::class => [ - \App\Cron\Hourly\RemoveExpiredBids::class + \App\Cron\Hourly\RemoveExpiredBids::class, ], ]; } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 7f6f5750..f9874799 100755 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -14,7 +14,7 @@ class EventServiceProvider extends ServiceProvider { protected $listen = [ Expenses::class => [ - ExpenseListener::class + ExpenseListener::class, ], UserStatsChanged::class => [ diff --git a/app/Providers/ExtendedTimezonelistProvider.php b/app/Providers/ExtendedTimezonelistProvider.php index 3c5a8912..13c83d9d 100644 --- a/app/Providers/ExtendedTimezonelistProvider.php +++ b/app/Providers/ExtendedTimezonelistProvider.php @@ -24,7 +24,7 @@ class ExtendedTimezonelistProvider extends ServiceProvider public function register() { $this->app->singleton('timezonelist', function ($app) { - return new TimezonelistExtended; + return new TimezonelistExtended(); }); } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 07079a18..12e9f337 100755 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -67,7 +67,7 @@ class RouteServiceProvider extends ServiceProvider { Route::group([ 'middleware' => ['api'], - 'namespace' => $this->namespace."\\Api", + 'namespace' => $this->namespace.'\\Api', 'prefix' => 'api', 'as' => 'api.', ], function ($router) { diff --git a/app/Providers/vaCentralServiceProvider.php b/app/Providers/vaCentralServiceProvider.php index 361baeaf..d9a3dc79 100755 --- a/app/Providers/vaCentralServiceProvider.php +++ b/app/Providers/vaCentralServiceProvider.php @@ -7,7 +7,6 @@ use VaCentral\VaCentral; /** * Bootstrap the vaCentral library - * @package App\Providers */ class vaCentralServiceProvider extends ServiceProvider { diff --git a/app/Repositories/AcarsRepository.php b/app/Repositories/AcarsRepository.php index 3e1311e1..65abfe09 100644 --- a/app/Repositories/AcarsRepository.php +++ b/app/Repositories/AcarsRepository.php @@ -11,7 +11,6 @@ use Carbon\Carbon; /** * Class AcarsRepository - * @package App\Repositories */ class AcarsRepository extends Repository { @@ -26,6 +25,7 @@ class AcarsRepository extends Repository /** * @param $pirep_id * @param $type + * * @return mixed */ public function forPirep($pirep_id, $type) @@ -52,7 +52,9 @@ class AcarsRepository extends Repository /** * Get all of the PIREPS that are in-progress, and then * get the latest update for those flights + * * @param int $live_time Age in hours of the oldest flights to show + * * @return Pirep */ public function getPositions($live_time = 0) @@ -60,7 +62,7 @@ class AcarsRepository extends Repository $q = Pirep::with(['airline', 'position', 'aircraft']) ->where(['state' => PirepState::IN_PROGRESS]); - if($live_time !== null && $live_time > 0) { + if ($live_time !== null && $live_time > 0) { $st = Carbon::now('UTC')->subHours($live_time); $q = $q->whereDate('created_at', '>=', $st); } @@ -75,7 +77,7 @@ class AcarsRepository extends Repository public function getAllAcarsPoints() { return Pirep::with('acars')->where([ - 'state' => PirepState::IN_PROGRESS + 'state' => PirepState::IN_PROGRESS, ]); } } diff --git a/app/Repositories/AircraftRepository.php b/app/Repositories/AircraftRepository.php index 2c2bfcb8..a273aeee 100644 --- a/app/Repositories/AircraftRepository.php +++ b/app/Repositories/AircraftRepository.php @@ -9,7 +9,6 @@ use Prettus\Repository\Traits\CacheableRepository; /** * Class AircraftRepository - * @package App\Repositories */ class AircraftRepository extends Repository implements CacheableInterface { @@ -28,6 +27,7 @@ class AircraftRepository extends Repository implements CacheableInterface /** * Return the list of aircraft formatted for a select box + * * @return array */ public function selectBoxList(): array diff --git a/app/Repositories/AirlineRepository.php b/app/Repositories/AirlineRepository.php index abb7d8f9..6f98c042 100644 --- a/app/Repositories/AirlineRepository.php +++ b/app/Repositories/AirlineRepository.php @@ -9,7 +9,6 @@ use Prettus\Repository\Traits\CacheableRepository; /** * Class AirlineRepository - * @package App\Repositories */ class AirlineRepository extends Repository implements CacheableInterface { @@ -27,6 +26,9 @@ class AirlineRepository extends Repository implements CacheableInterface /** * Return the list of airline formatted for a select box + * + * @param mixed $add_blank + * * @return array */ public function selectBoxList($add_blank = false): array diff --git a/app/Repositories/AirportRepository.php b/app/Repositories/AirportRepository.php index fabb96bf..9c707ef0 100644 --- a/app/Repositories/AirportRepository.php +++ b/app/Repositories/AirportRepository.php @@ -9,7 +9,6 @@ use Prettus\Repository\Traits\CacheableRepository; /** * Class AirportRepository - * @package App\Repositories */ class AirportRepository extends Repository implements CacheableInterface { @@ -27,6 +26,10 @@ class AirportRepository extends Repository implements CacheableInterface /** * Return the list of airports formatted for a select box + * + * @param mixed $add_blank + * @param mixed $only_hubs + * * @return array */ public function selectBoxList($add_blank = false, $only_hubs = false): array diff --git a/app/Repositories/AwardRepository.php b/app/Repositories/AwardRepository.php index 6b731bfc..5511ecba 100755 --- a/app/Repositories/AwardRepository.php +++ b/app/Repositories/AwardRepository.php @@ -9,7 +9,6 @@ use Prettus\Repository\Traits\CacheableRepository; /** * Class AwardRepository - * @package App\Repositories */ class AwardRepository extends Repository implements CacheableInterface { diff --git a/app/Repositories/Criteria/WhereCriteria.php b/app/Repositories/Criteria/WhereCriteria.php index 2a32a4cb..97fb2caf 100644 --- a/app/Repositories/Criteria/WhereCriteria.php +++ b/app/Repositories/Criteria/WhereCriteria.php @@ -9,14 +9,14 @@ use Prettus\Repository\Contracts\RepositoryInterface; /** * Class RequestCriteria - * @package Prettus\Repository\Criteria */ class WhereCriteria implements CriteriaInterface { /** * @var \Illuminate\Http\Request */ - protected $request, $where; + protected $request; + protected $where; public function __construct($request, $where) { @@ -27,11 +27,12 @@ class WhereCriteria implements CriteriaInterface /** * Apply criteria in query repository * - * @param Builder|Model $model - * @param RepositoryInterface $repository + * @param Builder|Model $model + * @param RepositoryInterface $repository + * + * @throws \Exception * * @return mixed - * @throws \Exception */ public function apply($model, RepositoryInterface $repository) { diff --git a/app/Repositories/ExpenseRepository.php b/app/Repositories/ExpenseRepository.php index dfb842b9..5b1e8018 100644 --- a/app/Repositories/ExpenseRepository.php +++ b/app/Repositories/ExpenseRepository.php @@ -10,7 +10,6 @@ use Prettus\Repository\Traits\CacheableRepository; /** * Class ExpenseRepository - * @package App\Repositories */ class ExpenseRepository extends Repository implements CacheableInterface { @@ -24,16 +23,18 @@ class ExpenseRepository extends Repository implements CacheableInterface /** * Get all of the expenses for a given type, and also * include expenses for a given airline ID + * * @param $type * @param null $airline_id * @param null $ref_model + * * @return Collection */ public function getAllForType($type, $airline_id = null, $ref_model = null) { $where = [ 'type' => $type, - ['airline_id', '=', null] + ['airline_id', '=', null], ]; if ($ref_model) { @@ -53,7 +54,7 @@ class ExpenseRepository extends Repository implements CacheableInterface if ($airline_id) { $where = [ 'type' => $type, - 'airline_id' => $airline_id + 'airline_id' => $airline_id, ]; if ($ref_model) { diff --git a/app/Repositories/FareRepository.php b/app/Repositories/FareRepository.php index c5833ca2..4ca6159e 100644 --- a/app/Repositories/FareRepository.php +++ b/app/Repositories/FareRepository.php @@ -9,7 +9,6 @@ use Prettus\Repository\Traits\CacheableRepository; /** * Class FareRepository - * @package App\Repositories */ class FareRepository extends Repository implements CacheableInterface { diff --git a/app/Repositories/FlightFieldRepository.php b/app/Repositories/FlightFieldRepository.php index df2cbe9b..4e5db697 100644 --- a/app/Repositories/FlightFieldRepository.php +++ b/app/Repositories/FlightFieldRepository.php @@ -7,7 +7,6 @@ use App\Models\FlightField; /** * Class FlightFieldRepository - * @package App\Repositories */ class FlightFieldRepository extends Repository { diff --git a/app/Repositories/FlightRepository.php b/app/Repositories/FlightRepository.php index c9762514..ee789744 100644 --- a/app/Repositories/FlightRepository.php +++ b/app/Repositories/FlightRepository.php @@ -11,7 +11,6 @@ use Prettus\Repository\Traits\CacheableRepository; /** * Class FlightRepository - * @package App\Repositories */ class FlightRepository extends Repository implements CacheableInterface { @@ -34,10 +33,12 @@ class FlightRepository extends Repository implements CacheableInterface /** * Find a flight based on the given criterea + * * @param $airline_id * @param $flight_num * @param null $route_code * @param null $route_leg + * * @return mixed */ public function findFlight($airline_id, $flight_num, $route_code = null, $route_leg = null) @@ -61,17 +62,20 @@ class FlightRepository extends Repository implements CacheableInterface /** * Create the search criteria and return this with the stuff pushed + * * @param Request $request * @param bool $only_active - * @return $this + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return $this */ public function searchCriteria(Request $request, bool $only_active = true) { $where = []; if ($only_active === true) { - $where['active'] = $only_active; + $where['active'] = $only_active; $where['visible'] = $only_active; } diff --git a/app/Repositories/JournalRepository.php b/app/Repositories/JournalRepository.php index 02513697..ba650495 100644 --- a/app/Repositories/JournalRepository.php +++ b/app/Repositories/JournalRepository.php @@ -14,7 +14,6 @@ use Prettus\Validator\Exceptions\ValidatorException; /** * Class JournalRepository - * @package App\Repositories */ class JournalRepository extends Repository implements CacheableInterface { @@ -30,13 +29,15 @@ class JournalRepository extends Repository implements CacheableInterface /** * Return a Y-m-d string for the post date + * * @param Carbon $date + * * @return string */ public function formatPostDate(Carbon $date = null) { if (!$date) { - return null; + return; } return $date->setTimezone('UTC')->toDateString(); @@ -44,15 +45,18 @@ class JournalRepository extends Repository implements CacheableInterface /** * Recalculate the balance of the given journal + * * @param Journal $journal - * @return Journal + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException + * + * @return Journal */ public function recalculateBalance(Journal $journal) { $where = [ - 'journal_id' => $journal->id + 'journal_id' => $journal->id, ]; $credits = Money::create($this->findWhere($where)->sum('credit') ?: 0); @@ -71,15 +75,17 @@ class JournalRepository extends Repository implements CacheableInterface * balance nightly, since they're not atomic operations * * @param Journal $journal - * @param Money|null $credit Amount to credit - * @param Money|null $debit Amount to debit - * @param Model|null $reference The object this is a reference to - * @param string|null $memo Memo for this transaction - * @param string|null $post_date Date of the posting + * @param Money|null $credit Amount to credit + * @param Money|null $debit Amount to debit + * @param Model|null $reference The object this is a reference to + * @param string|null $memo Memo for this transaction + * @param string|null $post_date Date of the posting * @param string|null $transaction_group * @param array|string|null $tags - * @return mixed + * * @throws ValidatorException + * + * @return mixed */ public function post( Journal &$journal, @@ -90,9 +96,8 @@ class JournalRepository extends Repository implements CacheableInterface $post_date = null, $transaction_group = null, $tags = null - ) - { - # tags can be passed in a list + ) { + // tags can be passed in a list if ($tags && \is_array($tags)) { $tags = implode(',', $tags); } @@ -109,7 +114,7 @@ class JournalRepository extends Repository implements CacheableInterface 'memo' => $memo, 'post_date' => $post_date, 'transaction_group' => $transaction_group, - 'tags' => $tags + 'tags' => $tags, ]; if ($reference !== null) { @@ -131,9 +136,11 @@ class JournalRepository extends Repository implements CacheableInterface /** * @param Journal $journal * @param Carbon|null $date - * @return Money + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException + * + * @return Money */ public function getBalance(Journal $journal = null, Carbon $date = null) { @@ -151,21 +158,23 @@ class JournalRepository extends Repository implements CacheableInterface /** * Get the credit only balance of the journal based on a given date. + * * @param Carbon $date * @param Journal $journal * @param Carbon|null $start_date * @param null $transaction_group - * @return Money + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException + * + * @return Money */ public function getCreditBalanceBetween( Carbon $date, Journal $journal = null, Carbon $start_date = null, $transaction_group = null - ): Money - { + ): Money { $where = []; if ($journal) { @@ -193,17 +202,18 @@ class JournalRepository extends Repository implements CacheableInterface * @param Journal $journal * @param Carbon|null $start_date * @param null $transaction_group - * @return Money + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException + * + * @return Money */ public function getDebitBalanceBetween( Carbon $date, Journal $journal = null, Carbon $start_date = null, $transaction_group = null - ): Money - { + ): Money { $where = []; if ($journal) { @@ -228,12 +238,15 @@ class JournalRepository extends Repository implements CacheableInterface /** * Return all transactions for a given object + * * @param $object * @param null $journal * @param Carbon|null $date - * @return array + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException + * + * @return array */ public function getAllForObject($object, $journal = null, Carbon $date = null) { @@ -253,7 +266,7 @@ class JournalRepository extends Repository implements CacheableInterface $transactions = $this->whereOrder($where, [ 'credit' => 'desc', - 'debit' => 'desc' + 'debit' => 'desc', ])->get(); return [ @@ -265,8 +278,10 @@ class JournalRepository extends Repository implements CacheableInterface /** * Delete all transactions for a given object + * * @param $object * @param null $journal + * * @return void */ public function deleteAllForObject($object, $journal = null) diff --git a/app/Repositories/NavdataRepository.php b/app/Repositories/NavdataRepository.php index 9ed69a80..b7ef3316 100644 --- a/app/Repositories/NavdataRepository.php +++ b/app/Repositories/NavdataRepository.php @@ -9,7 +9,6 @@ use Prettus\Repository\Traits\CacheableRepository; /** * Class NavdataRepository - * @package App\Repositories */ class NavdataRepository extends Repository implements CacheableInterface { diff --git a/app/Repositories/NewsRepository.php b/app/Repositories/NewsRepository.php index 819e42b4..cada9239 100644 --- a/app/Repositories/NewsRepository.php +++ b/app/Repositories/NewsRepository.php @@ -9,7 +9,6 @@ use Prettus\Repository\Traits\CacheableRepository; /** * Class NewsRepository - * @package App\Repositories */ class NewsRepository extends Repository implements CacheableInterface { @@ -22,7 +21,9 @@ class NewsRepository extends Repository implements CacheableInterface /** * Latest news items + * * @param int $count + * * @return mixed */ public function getLatest($count = 5) diff --git a/app/Repositories/PirepFieldRepository.php b/app/Repositories/PirepFieldRepository.php index b17b1c99..861f65bf 100644 --- a/app/Repositories/PirepFieldRepository.php +++ b/app/Repositories/PirepFieldRepository.php @@ -7,7 +7,6 @@ use App\Models\PirepField; /** * Class PirepFieldRepository - * @package App\Repositories */ class PirepFieldRepository extends Repository { diff --git a/app/Repositories/PirepRepository.php b/app/Repositories/PirepRepository.php index f7f74960..774efd9e 100644 --- a/app/Repositories/PirepRepository.php +++ b/app/Repositories/PirepRepository.php @@ -9,7 +9,6 @@ use App\Models\User; /** * Class PirepRepository - * @package App\Repositories */ class PirepRepository extends Repository { @@ -30,7 +29,9 @@ class PirepRepository extends Repository /** * Get all the pending reports in order. Returns the Pirep * model but you still need to call ->all() or ->paginate() + * * @param User|null $user + * * @return Pirep */ public function getPending(User $user = null) @@ -47,7 +48,9 @@ class PirepRepository extends Repository /** * Number of PIREPs that are pending + * * @param User|null $user + * * @return mixed */ public function getPendingCount(User $user = null) diff --git a/app/Repositories/RankRepository.php b/app/Repositories/RankRepository.php index 9b466983..659b6e3b 100644 --- a/app/Repositories/RankRepository.php +++ b/app/Repositories/RankRepository.php @@ -9,7 +9,6 @@ use Prettus\Repository\Traits\CacheableRepository; /** * Class RankRepository - * @package App\Repositories */ class RankRepository extends Repository implements CacheableInterface { diff --git a/app/Repositories/SettingRepository.php b/app/Repositories/SettingRepository.php index d5541e8f..bfa60142 100644 --- a/app/Repositories/SettingRepository.php +++ b/app/Repositories/SettingRepository.php @@ -13,7 +13,6 @@ use Prettus\Validator\Exceptions\ValidatorException; /** * Class SettingRepository - * @package App\Repositories */ class SettingRepository extends Repository implements CacheableInterface { @@ -31,9 +30,12 @@ class SettingRepository extends Repository implements CacheableInterface /** * Get a setting, reading it from the cache possibly + * * @param string $key - * @return mixed + * * @throws SettingNotFound + * + * @return mixed */ public function retrieve($key) { @@ -44,7 +46,7 @@ class SettingRepository extends Repository implements CacheableInterface throw new SettingNotFound($key.' not found'); } - # cast some types + // cast some types switch ($setting->type) { case 'bool': case 'boolean': @@ -75,6 +77,9 @@ class SettingRepository extends Repository implements CacheableInterface /** * @alias store($key,$value) + * + * @param mixed $key + * @param mixed $value */ public function save($key, $value) { @@ -84,8 +89,10 @@ class SettingRepository extends Repository implements CacheableInterface /** * Update an existing setting with a new value. Doesn't create * a new setting + * * @param $key * @param $value + * * @return null */ public function store($key, $value) @@ -93,11 +100,11 @@ class SettingRepository extends Repository implements CacheableInterface $key = Setting::formatKey($key); $setting = $this->findWhere( ['id' => $key], - ['id', 'value'] # only get these columns + ['id', 'value'] // only get these columns )->first(); if (!$setting) { - return null; + return; } try { diff --git a/app/Repositories/SubfleetRepository.php b/app/Repositories/SubfleetRepository.php index 9e0c9467..ccd6caa0 100644 --- a/app/Repositories/SubfleetRepository.php +++ b/app/Repositories/SubfleetRepository.php @@ -9,7 +9,6 @@ use Prettus\Repository\Traits\CacheableRepository; /** * Class SubfleetRepository - * @package App\Repositories */ class SubfleetRepository extends Repository implements CacheableInterface { diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index a9e4c6a9..e3f614a9 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -10,7 +10,6 @@ use Illuminate\Http\Request; /** * Class UserRepository - * @package App\Repositories */ class UserRepository extends Repository { @@ -19,7 +18,7 @@ class UserRepository extends Repository 'email' => 'like', 'home_airport_id', 'curr_airport_id', - 'state' + 'state', ]; /** @@ -32,6 +31,7 @@ class UserRepository extends Repository /** * Number of PIREPs that are pending + * * @return mixed */ public function getPendingCount() @@ -49,10 +49,13 @@ class UserRepository extends Repository /** * Create the search criteria and return this with the stuff pushed + * * @param Request $request * @param bool $only_active - * @return $this + * * @throws \Prettus\Repository\Exceptions\RepositoryException + * + * @return $this */ public function searchCriteria(Request $request, bool $only_active = true) { diff --git a/app/Routes/admin.php b/app/Routes/admin.php index 0375a71a..359cea3c 100644 --- a/app/Routes/admin.php +++ b/app/Routes/admin.php @@ -2,7 +2,6 @@ /** * Admin Routes */ - Route::group([ 'namespace' => 'Admin', 'prefix' => 'admin', 'as' => 'admin.', 'middleware' => ['role:admin'], @@ -15,33 +14,33 @@ Route::group([ Route::match(['get', 'post', 'put', 'delete'], 'airports/{id}/expenses', 'AirportController@expenses'); Route::resource('airports', 'AirportController'); - # Awards + // Awards Route::resource('awards', 'AwardController'); - # aircraft and fare associations + // aircraft and fare associations Route::get('aircraft/export', 'AircraftController@export')->name('aircraft.export'); Route::match(['get', 'post'], 'aircraft/import', 'AircraftController@import')->name('aircraft.import'); Route::match(['get', 'post', 'put', 'delete'], 'aircraft/{id}/expenses', 'AircraftController@expenses'); Route::resource('aircraft', 'AircraftController'); - # expenses + // expenses Route::get('expenses/export', 'ExpenseController@export')->name('expenses.export'); Route::match(['get', 'post'], 'expenses/import', 'ExpenseController@import')->name('expenses.import'); Route::resource('expenses', 'ExpenseController'); - # fares + // fares Route::get('fares/export', 'FareController@export')->name('fares.export'); Route::match(['get', 'post'], 'fares/import', 'FareController@import')->name('fares.import'); Route::resource('fares', 'FareController'); - # files + // files Route::post('files', 'FileController@store')->name('files.store'); Route::delete('files/{id}', 'FileController@destroy')->name('files.delete'); - # finances + // finances Route::resource('finances', 'FinanceController'); - # flights and aircraft associations + // flights and aircraft associations Route::get('flights/export', 'FlightController@export')->name('flights.export'); Route::match(['get', 'post'], 'flights/import', 'FlightController@import')->name('flights.import'); Route::match(['get', 'post', 'put', 'delete'], 'flights/{id}/fares', 'FlightController@fares'); @@ -51,7 +50,7 @@ Route::group([ Route::resource('flightfields', 'FlightFieldController'); - # pirep related routes + // pirep related routes Route::get('pireps/fares', 'PirepController@fares'); Route::get('pireps/pending', 'PirepController@pending'); Route::resource('pireps', 'PirepController'); @@ -60,15 +59,15 @@ Route::group([ Route::resource('pirepfields', 'PirepFieldController'); - # rankings + // rankings Route::resource('ranks', 'RankController'); Route::match(['get', 'post', 'put', 'delete'], 'ranks/{id}/subfleets', 'RankController@subfleets'); - # settings + // settings Route::match(['get'], 'settings', 'SettingsController@index'); Route::match(['post', 'put'], 'settings', 'SettingsController@update')->name('settings.update'); - # subfleet + // subfleet Route::get('subfleets/export', 'SubfleetController@export')->name('subfleets.export'); Route::match(['get', 'post'], 'subfleets/import', 'SubfleetController@import')->name('subfleets.import'); Route::match(['get', 'post', 'put', 'delete'], 'subfleets/{id}/expenses', 'SubfleetController@expenses'); @@ -80,7 +79,7 @@ Route::group([ Route::get('users/{id}/regen_apikey', 'UserController@regen_apikey')->name('users.regen_apikey'); - # defaults + // defaults Route::get('', ['uses' => 'DashboardController@index']); Route::get('/', ['uses' => 'DashboardController@index']); diff --git a/app/Routes/api.php b/app/Routes/api.php index 0d76f2e7..b9ba7515 100755 --- a/app/Routes/api.php +++ b/app/Routes/api.php @@ -14,7 +14,7 @@ Route::group([], function () { Route::get('version', 'StatusController@status'); }); -/** +/* * these need to be authenticated with a user's API key */ Route::group(['middleware' => ['api.auth']], function () { @@ -48,7 +48,6 @@ Route::group(['middleware' => ['api.auth']], function () { Route::get('pireps/{pirep_id}/fields', 'PirepController@fields_get'); Route::post('pireps/{pirep_id}/fields', 'PirepController@fields_post'); - Route::get('pireps/{pirep_id}/finances', 'PirepController@finances_get'); Route::post('pireps/{pirep_id}/finances/recalculate', 'PirepController@finances_recalculate'); @@ -67,7 +66,7 @@ Route::group(['middleware' => ['api.auth']], function () { Route::get('settings', 'SettingsController@index'); - # This is the info of the user whose token is in use + // This is the info of the user whose token is in use Route::get('user', 'UserController@index'); Route::get('user/fleet', 'UserController@fleet'); Route::get('user/pireps', 'UserController@pireps'); diff --git a/app/Routes/web.php b/app/Routes/web.php index 72fd4729..343c88c4 100755 --- a/app/Routes/web.php +++ b/app/Routes/web.php @@ -4,7 +4,7 @@ * User doesn't need to be logged in for these */ Route::group([ - 'namespace' => 'Frontend', 'prefix' => '', 'as' => 'frontend.' + 'namespace' => 'Frontend', 'prefix' => '', 'as' => 'frontend.', ], function () { Route::get('/', 'HomeController@index')->name('home'); Route::get('r/{id}', 'PirepController@show')->name('pirep.show.public'); @@ -16,7 +16,7 @@ Route::group([ Route::get('livemap', 'AcarsController@index')->name('livemap.index'); }); -/** +/* * These are only visible to a logged in user */ Route::group([ diff --git a/app/Services/AnalyticsService.php b/app/Services/AnalyticsService.php index 62a639fb..03704cf1 100644 --- a/app/Services/AnalyticsService.php +++ b/app/Services/AnalyticsService.php @@ -11,7 +11,6 @@ use PDO; /** * Class AnalyticsService - * @package App\Services */ class AnalyticsService extends Service { @@ -24,13 +23,13 @@ class AnalyticsService extends Service return; } - # some analytics + // some analytics $gamp = GAMP::setClientId(uniqid('', true)); $gamp->setDocumentPath('/install'); $gamp->setCustomDimension(PHP_VERSION, AnalyticsDimensions::PHP_VERSION); - # figure out database version + // figure out database version $pdo = DB::connection()->getPdo(); $gamp->setCustomDimension( strtolower($pdo->getAttribute(PDO::ATTR_SERVER_VERSION)), diff --git a/app/Services/AwardService.php b/app/Services/AwardService.php index 01462116..9c4657e6 100644 --- a/app/Services/AwardService.php +++ b/app/Services/AwardService.php @@ -8,12 +8,12 @@ use Module; /** * Class AwardService - * @package App\Services */ class AwardService extends Service { /** * Find any of the award classes + * * @return \App\Interfaces\Award[] */ public function findAllAwardClasses(): array @@ -21,11 +21,11 @@ class AwardService extends Service $awards = []; $formatted_awards = []; - # Find the awards in the app/Awards directory + // Find the awards in the app/Awards directory $classes = ClassLoader::getClassesInPath(app_path('/Awards')); $awards = array_merge($awards, $classes); - # Look throughout all the other modules, in the module/{MODULE}/Awards directory + // Look throughout all the other modules, in the module/{MODULE}/Awards directory foreach (Module::all() as $module) { $path = $module->getExtraPath('Awards'); $classes = ClassLoader::getClassesInPath($path); diff --git a/app/Services/DatabaseService.php b/app/Services/DatabaseService.php index bbd0020a..f3f43104 100644 --- a/app/Services/DatabaseService.php +++ b/app/Services/DatabaseService.php @@ -9,13 +9,12 @@ use Webpatser\Uuid\Uuid; /** * Class DatabaseService - * @package App\Services */ class DatabaseService extends Service { protected $time_fields = [ 'created_at', - 'updated_at' + 'updated_at', ]; protected $uuid_tables = [ @@ -35,8 +34,10 @@ class DatabaseService extends Service /** * @param $yaml_file * @param bool $ignore_errors - * @return array + * * @throws \Exception + * + * @return array */ public function seed_from_yaml_file($yaml_file, $ignore_errors = false): array { @@ -46,8 +47,10 @@ class DatabaseService extends Service /** * @param $yml * @param bool $ignore_errors - * @return array + * * @throws \Exception + * + * @return array */ public function seed_from_yaml($yml, $ignore_errors = false): array { @@ -55,14 +58,17 @@ class DatabaseService extends Service } /** - * @param $table - * @param $row - * @return mixed + * @param $table + * @param $row + * * @throws \Exception + * + * @return mixed */ - public function insert_row($table, $row) { - # see if this table uses a UUID as the PK - # if no ID is specified + public function insert_row($table, $row) + { + // see if this table uses a UUID as the PK + // if no ID is specified if (\in_array($table, $this->uuid_tables, true)) { if (!array_key_exists('id', $row)) { $row['id'] = Uuid::generate()->string; diff --git a/app/Services/ExportService.php b/app/Services/ExportService.php index bfe5d9bc..0298187a 100644 --- a/app/Services/ExportService.php +++ b/app/Services/ExportService.php @@ -11,19 +11,19 @@ use App\Services\ImportExport\FareExporter; use App\Services\ImportExport\FlightExporter; use App\Services\ImportExport\SubfleetExporter; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Storage; use League\Csv\CharsetConverter; use League\Csv\Writer; -use Illuminate\Support\Facades\Storage; use Log; /** * Class ExportService - * @package App\Services */ class ExportService extends Service { /** - * @param string $path + * @param string $path + * * @return Writer */ public function openCsv($path): Writer @@ -35,20 +35,23 @@ class ExportService extends Service /** * Run the actual importer + * * @param Collection $collection * @param ImportExport $exporter - * @return string + * * @throws \League\Csv\CannotInsertRecord + * + * @return string */ protected function runExport(Collection $collection, ImportExport $exporter): string { - $filename = 'export_' . $exporter->assetType . '.csv'; + $filename = 'export_'.$exporter->assetType.'.csv'; // Create the directory - makes it inside of storage/app Storage::makeDirectory('import'); $path = storage_path('/app/import/export_'.$filename.'.csv'); - Log::info('Exporting "'.$exporter->assetType.'" to ' . $path); + Log::info('Exporting "'.$exporter->assetType.'" to '.$path); $writer = $this->openCsv($path); @@ -65,9 +68,12 @@ class ExportService extends Service /** * Export all of the aircraft + * * @param Collection $aircraft - * @return mixed + * * @throws \League\Csv\CannotInsertRecord + * + * @return mixed */ public function exportAircraft($aircraft) { @@ -77,9 +83,12 @@ class ExportService extends Service /** * Export all of the airports + * * @param Collection $airports - * @return mixed + * * @throws \League\Csv\CannotInsertRecord + * + * @return mixed */ public function exportAirports($airports) { @@ -89,9 +98,12 @@ class ExportService extends Service /** * Export all of the airports + * * @param Collection $expenses - * @return mixed + * * @throws \League\Csv\CannotInsertRecord + * + * @return mixed */ public function exportExpenses($expenses) { @@ -101,9 +113,12 @@ class ExportService extends Service /** * Export all of the fares + * * @param Collection $fares - * @return mixed + * * @throws \League\Csv\CannotInsertRecord + * + * @return mixed */ public function exportFares($fares) { @@ -113,9 +128,12 @@ class ExportService extends Service /** * Export all of the flights + * * @param Collection $flights - * @return mixed + * * @throws \League\Csv\CannotInsertRecord + * + * @return mixed */ public function exportFlights($flights) { @@ -125,9 +143,12 @@ class ExportService extends Service /** * Export all of the flights + * * @param Collection $subfleets - * @return mixed + * * @throws \League\Csv\CannotInsertRecord + * + * @return mixed */ public function exportSubfleets($subfleets) { diff --git a/app/Services/FareService.php b/app/Services/FareService.php index 3bb51020..5bdc1cd7 100644 --- a/app/Services/FareService.php +++ b/app/Services/FareService.php @@ -13,7 +13,6 @@ use Illuminate\Support\Collection; /** * Class FareService - * @package App\Services */ class FareService extends Service { @@ -24,8 +23,10 @@ class FareService extends Service * final "authoritative" list of the fares for a flight. * * If a subfleet is passed in, + * * @param Flight|null $flight * @param Subfleet|null $subfleet + * * @return Collection */ public function getAllFares($flight, $subfleet) @@ -38,8 +39,8 @@ class FareService extends Service $subfleet_fares = $this->getForSubfleet($subfleet); - # Go through all of the fares assigned by the subfleet - # See if any of the same fares are assigned to the flight + // Go through all of the fares assigned by the subfleet + // See if any of the same fares are assigned to the flight $fares = $subfleet_fares->map(function ($fare, $idx) use ($flight_fares) { $flight_fare = $flight_fares->whereStrict('id', $fare->id)->first(); if (!$flight_fare) { @@ -54,7 +55,9 @@ class FareService extends Service /** * Get fares + * * @param $fare + * * @return mixed */ protected function getFares($fare) @@ -92,19 +95,20 @@ class FareService extends Service * @param Flight $flight * @param Fare $fare * @param array set the price/cost/capacity + * * @return Flight */ public function setForFlight(Flight $flight, Fare $fare, array $override = []): Flight { $flight->fares()->syncWithoutDetaching([$fare->id]); - foreach($override as $key => $item) { - if(!$item) { + foreach ($override as $key => $item) { + if (!$item) { unset($override[$key]); } } - # modify any pivot values? + // modify any pivot values? if (\count($override) > 0) { $flight->fares()->updateExistingPivot($fare->id, $override); } @@ -119,7 +123,9 @@ class FareService extends Service * return all the fares for a flight. check the pivot * table to see if the price/cost/capacity has been overridden * and return the correct amounts. + * * @param Flight $flight + * * @return Collection */ public function getForFlight(Flight $flight) @@ -134,6 +140,7 @@ class FareService extends Service /** * @param Flight $flight * @param Fare $fare + * * @return Flight */ public function delFareFromFlight(Flight $flight, Fare $fare) @@ -150,13 +157,14 @@ class FareService extends Service * @param Subfleet $subfleet * @param Fare $fare * @param array set the price/cost/capacity + * * @return Subfleet */ public function setForSubfleet(Subfleet $subfleet, Fare $fare, array $override = []): Subfleet { $subfleet->fares()->syncWithoutDetaching([$fare->id]); - # modify any pivot values? + // modify any pivot values? if (count($override) > 0) { $subfleet->fares()->updateExistingPivot($fare->id, $override); } @@ -171,7 +179,9 @@ class FareService extends Service * return all the fares for an aircraft. check the pivot * table to see if the price/cost/capacity has been overridden * and return the correct amounts. + * * @param Subfleet $subfleet + * * @return Collection */ public function getForSubfleet(Subfleet $subfleet) @@ -185,8 +195,10 @@ class FareService extends Service /** * Delete the fare from a subfleet + * * @param Subfleet $subfleet * @param Fare $fare + * * @return Subfleet|null|static */ public function delFareFromSubfleet(Subfleet &$subfleet, Fare &$fare) @@ -200,7 +212,9 @@ class FareService extends Service /** * Get the fares for a PIREP, this just returns the PirepFare * model which includes the counts for that particular fare + * * @param Pirep $pirep + * * @return Collection */ public function getForPirep(Pirep $pirep) @@ -213,8 +227,10 @@ class FareService extends Service /** * Save the list of fares + * * @param Pirep $pirep * @param array $fares ['fare_id', 'count'] + * * @throws \Exception */ public function saveForPirep(Pirep $pirep, array $fares) @@ -223,13 +239,13 @@ class FareService extends Service return; } - # Remove all the previous fares + // Remove all the previous fares PirepFare::where('pirep_id', $pirep->id)->delete(); - # Add them in + // Add them in foreach ($fares as $fare) { $fare['pirep_id'] = $pirep->id; - # other fields: ['fare_id', 'count'] + // other fields: ['fare_id', 'count'] $field = new PirepFare($fare); $field->save(); diff --git a/app/Services/FileService.php b/app/Services/FileService.php index 02f7322d..46a8730e 100644 --- a/app/Services/FileService.php +++ b/app/Services/FileService.php @@ -7,17 +7,19 @@ use App\Models\File; /** * Class FileService - * @package App\Services */ class FileService extends Service { /** * Save a file to disk and return a File asset + * * @param \Illuminate\Http\UploadedFile $file * @param string $folder * @param array $attrs - * @return File + * * @throws \Hashids\HashidsException + * + * @return File */ public function saveFile($file, $folder, array $attrs) { @@ -33,12 +35,12 @@ class FileService extends Service $id = File::createNewHashId(); $path_info = pathinfo($file->getClientOriginalName()); - # Create the file, add the ID to the front of the file to account - # for any duplicate filenames, but still can be found in an `ls` + // Create the file, add the ID to the front of the file to account + // for any duplicate filenames, but still can be found in an `ls` - $filename = $id . '_' - . str_slug(trim($path_info['filename'])) - . '.' . $path_info['extension']; + $filename = $id.'_' + .str_slug(trim($path_info['filename'])) + .'.'.$path_info['extension']; $file_path = $file->storeAs($folder, $filename, $attrs['disk']); diff --git a/app/Services/Finance/PirepFinanceService.php b/app/Services/Finance/PirepFinanceService.php index 66b20531..e4169e92 100644 --- a/app/Services/Finance/PirepFinanceService.php +++ b/app/Services/Finance/PirepFinanceService.php @@ -18,18 +18,17 @@ use Log; /** * Class FinanceService - * @package App\Services - * */ class PirepFinanceService extends Service { - private $expenseRepo, - $fareSvc, - $journalRepo, - $pirepSvc; + private $expenseRepo; + private $fareSvc; + private $journalRepo; + private $pirepSvc; /** * FinanceService constructor. + * * @param ExpenseRepository $expenseRepo * @param FareService $fareSvc * @param JournalRepository $journalRepo @@ -40,8 +39,7 @@ class PirepFinanceService extends Service FareService $fareSvc, JournalRepository $journalRepo, PirepService $pirepSvc - ) - { + ) { $this->expenseRepo = $expenseRepo; $this->fareSvc = $fareSvc; $this->journalRepo = $journalRepo; @@ -51,12 +49,15 @@ class PirepFinanceService extends Service /** * Process all of the finances for a pilot report. This is called * from a listener (FinanceEvents) + * * @param Pirep $pirep - * @return mixed + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException * @throws \Prettus\Validator\Exceptions\ValidatorException * @throws \Exception + * + * @return mixed */ public function processFinancesForPirep(Pirep $pirep) { @@ -68,12 +69,12 @@ class PirepFinanceService extends Service $pirep->user->journal = $pirep->user->initJournal(config('phpvms.currency')); } - # Clean out the expenses first + // Clean out the expenses first $this->deleteFinancesForPirep($pirep); Log::info('Finance: Starting PIREP pay for '.$pirep->id); - # Now start and pay from scratch + // Now start and pay from scratch $this->payFaresForPirep($pirep); $this->payExpensesForSubfleet($pirep); $this->payExpensesForPirep($pirep); @@ -102,7 +103,9 @@ class PirepFinanceService extends Service /** * Collect all of the fares and then post each fare class's profit and * the costs for each seat and post it to the journal + * * @param $pirep + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException * @throws \Prettus\Validator\Exceptions\ValidatorException @@ -137,7 +140,9 @@ class PirepFinanceService extends Service /** * Calculate what the cost is for the operating an aircraft * in this subfleet, as-per the block time + * * @param Pirep $pirep + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException * @throws \Prettus\Validator\Exceptions\ValidatorException @@ -146,18 +151,18 @@ class PirepFinanceService extends Service { $sf = $pirep->aircraft->subfleet; - # Haven't entered a cost + // Haven't entered a cost if (!filled($sf->cost_block_hour)) { return; } - # Convert to cost per-minute + // Convert to cost per-minute $cost_per_min = round($sf->cost_block_hour / 60, 2); - # Time to use - use the block time if it's there, actual - # flight time if that hasn't been used + // Time to use - use the block time if it's there, actual + // flight time if that hasn't been used $block_time = $pirep->block_time; - if(!filled($block_time)) { + if (!filled($block_time)) { Log::info('Finance: No block time, using PIREP flight time'); $block_time = $pirep->flight_time; } @@ -179,7 +184,9 @@ class PirepFinanceService extends Service /** * Collect all of the expenses and apply those to the journal + * * @param Pirep $pirep + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException */ @@ -190,7 +197,7 @@ class PirepFinanceService extends Service $pirep->airline_id ); - /** + /* * Go through the expenses and apply a mulitplier if present */ $expenses->map(function ($expense, $i) use ($pirep) { @@ -200,16 +207,16 @@ class PirepFinanceService extends Service Log::info('Finance: PIREP: '.$pirep->id.', expense:', $expense->toArray()); - # Get the transaction group name from the ref_model name - # This way it can be more dynamic and don't have to add special - # tables or specific expense calls to accomodate all of these + // Get the transaction group name from the ref_model name + // This way it can be more dynamic and don't have to add special + // tables or specific expense calls to accomodate all of these $klass = 'Expense'; if ($expense->ref_model) { $ref = explode('\\', $expense->ref_model); $klass = end($ref); } - # Form the memo, with some specific ones depending on the group + // Form the memo, with some specific ones depending on the group if ($klass === 'Airport') { $memo = "Airport Expense: {$expense->name} ({$expense->ref_model_id})"; $transaction_group = "Airport: {$expense->ref_model_id}"; @@ -227,8 +234,8 @@ class PirepFinanceService extends Service $debit = Money::createFromAmount($expense->amount); - # If the expense is marked to charge it to a user (only applicable to Flight) - # then change the journal to the user's to debit there + // If the expense is marked to charge it to a user (only applicable to Flight) + // then change the journal to the user's to debit there $journal = $pirep->airline->journal; if ($expense->charge_to_user) { $journal = $pirep->user->journal; @@ -249,7 +256,9 @@ class PirepFinanceService extends Service /** * Collect all of the expenses from the listeners and apply those to the journal + * * @param Pirep $pirep + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException * @throws \Prettus\Validator\Exceptions\ValidatorException @@ -270,7 +279,7 @@ class PirepFinanceService extends Service } foreach ($event_expense as $expense) { - # Make sure it's of type expense Model + // Make sure it's of type expense Model if (!($expense instanceof Expense)) { continue; } @@ -278,8 +287,8 @@ class PirepFinanceService extends Service Log::info('Finance: Expense from listener, N="' .$expense->name.'", A='.$expense->amount); - # If an airline_id is filled, then see if it matches - if(filled($expense->airline_id) && $expense->airline_id !== $pirep->airline_id) { + // If an airline_id is filled, then see if it matches + if (filled($expense->airline_id) && $expense->airline_id !== $pirep->airline_id) { Log::info('Finance: Expense has an airline ID and it doesn\'t match, skipping'); continue; } @@ -302,7 +311,9 @@ class PirepFinanceService extends Service /** * Collect and apply the ground handling cost + * * @param Pirep $pirep + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException * @throws \Prettus\Validator\Exceptions\ValidatorException @@ -326,7 +337,9 @@ class PirepFinanceService extends Service /** * Figure out what the pilot pay is. Debit it from the airline journal * But also reference the PIREP + * * @param Pirep $pirep + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException * @throws \Prettus\Validator\Exceptions\ValidatorException @@ -373,12 +386,14 @@ class PirepFinanceService extends Service * capacity = max number of pax units * * If count > capacity, count will be adjusted to capacity + * * @param $pirep + * * @return \Illuminate\Support\Collection */ public function getReconciledFaresForPirep($pirep) { - # Collect all of the fares and prices + // Collect all of the fares and prices $flight_fares = $this->fareSvc->getForPirep($pirep); Log::info('Finance: PIREP: '.$pirep->id.', flight fares: ', $flight_fares->toArray()); @@ -392,8 +407,8 @@ class PirepFinanceService extends Service if ($fare_count) { Log::info('Finance: PIREP: '.$pirep->id.', fare count: '.$fare_count); - # If the count is greater than capacity, then just set it - # to the maximum amount + // If the count is greater than capacity, then just set it + // to the maximum amount if ($fare_count->count > $fare->capacity) { $fare->count = $fare->capacity; } else { @@ -412,7 +427,9 @@ class PirepFinanceService extends Service /** * Return the costs for the ground handling, with the multiplier * being applied from the subfleet + * * @param Pirep $pirep + * * @return float|null */ public function getGroundHandlingCost(Pirep $pirep) @@ -432,17 +449,20 @@ class PirepFinanceService extends Service /** * Return the pilot's hourly pay for the given PIREP + * * @param Pirep $pirep - * @return float + * * @throws \InvalidArgumentException + * + * @return float */ public function getPilotPayRateForPirep(Pirep $pirep) { - # Get the base rate for the rank + // Get the base rate for the rank $rank = $pirep->user->rank; $subfleet_id = $pirep->aircraft->subfleet_id; - # find the right subfleet + // find the right subfleet $override_rate = $rank->subfleets() ->where('subfleet_id', $subfleet_id) ->first(); @@ -477,10 +497,13 @@ class PirepFinanceService extends Service /** * Get the user's payment amount for a PIREP + * * @param Pirep $pirep - * @return Money + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException + * + * @return Money */ public function getPilotPay(Pirep $pirep) { diff --git a/app/Services/Finance/RecurringFinanceService.php b/app/Services/Finance/RecurringFinanceService.php index 9da71f37..894a0b40 100644 --- a/app/Services/Finance/RecurringFinanceService.php +++ b/app/Services/Finance/RecurringFinanceService.php @@ -13,7 +13,6 @@ use Log; /** * Process all of the daily expenses and charge them - * @package App\Services\Finance */ class RecurringFinanceService extends Service { @@ -21,6 +20,7 @@ class RecurringFinanceService extends Service /** * RecurringFinanceService constructor. + * * @param JournalRepository $journalRepo */ public function __construct(JournalRepository $journalRepo) @@ -31,7 +31,9 @@ class RecurringFinanceService extends Service /** * Determine the journal to charge to, otherwise, it's charged * to every airline journal + * * @param Expense $expense + * * @return \Generator */ protected function findJournals(Expense $expense) @@ -51,7 +53,9 @@ class RecurringFinanceService extends Service /** * Get the name of the transaction group from the expense + * * @param Expense $expense + * * @return array */ protected function getMemoAndGroup(Expense $expense): array @@ -82,7 +86,9 @@ class RecurringFinanceService extends Service /** * Run all of the daily expense/financials + * * @param int $type + * * @throws \UnexpectedValueException * @throws \InvalidArgumentException * @throws \Prettus\Validator\Exceptions\ValidatorException @@ -102,13 +108,13 @@ class RecurringFinanceService extends Service * @var $expenses Expense[] */ foreach ($expenses as $expense) { - # Apply the expenses to the appropriate journals + // Apply the expenses to the appropriate journals $journals = $this->findJournals($expense); foreach ($journals as $journal) { $amount = $expense->amount; - # Has this expense already been charged? Check - # against this specific journal, on today + // Has this expense already been charged? Check + // against this specific journal, on today $w = [ 'journal_id' => $journal->id, 'ref_model' => Expense::class, diff --git a/app/Services/FleetService.php b/app/Services/FleetService.php index f56e6021..659f5c17 100644 --- a/app/Services/FleetService.php +++ b/app/Services/FleetService.php @@ -9,7 +9,6 @@ use App\Models\Subfleet; /** * Class FleetService - * @package App\Services */ class FleetService extends Service { @@ -17,6 +16,7 @@ class FleetService extends Service * @param Subfleet $subfleet * @param Rank $rank * @param array $overrides + * * @return Subfleet */ public function addSubfleetToRank(Subfleet $subfleet, Rank $rank, array $overrides = []) @@ -45,6 +45,7 @@ class FleetService extends Service /** * Add the subfleet to a flight + * * @param Subfleet $subfleet * @param Flight $flight */ @@ -57,6 +58,7 @@ class FleetService extends Service /** * Remove the subfleet from a flight + * * @param Subfleet $subfleet * @param Flight $flight */ diff --git a/app/Services/FlightService.php b/app/Services/FlightService.php index 2dc213e3..89f75faf 100644 --- a/app/Services/FlightService.php +++ b/app/Services/FlightService.php @@ -14,17 +14,17 @@ use Log; /** * Class FlightService - * @package App\Services */ class FlightService extends Service { - private $fareSvc, - $flightRepo, - $navDataRepo, - $userSvc; + private $fareSvc; + private $flightRepo; + private $navDataRepo; + private $userSvc; /** * FlightService constructor. + * * @param FareService $fareSvc * @param FlightRepository $flightRepo * @param NavdataRepository $navdataRepo @@ -35,8 +35,7 @@ class FlightService extends Service FlightRepository $flightRepo, NavdataRepository $navdataRepo, UserService $userSvc - ) - { + ) { $this->fareSvc = $fareSvc; $this->flightRepo = $flightRepo; $this->navDataRepo = $navdataRepo; @@ -45,7 +44,9 @@ class FlightService extends Service /** * Filter out any flights according to different settings + * * @param $user + * * @return FlightRepository */ public function filterFlights($user) @@ -61,15 +62,17 @@ class FlightService extends Service /** * Filter out subfleets to only include aircraft that a user has access to + * * @param $user * @param $flight + * * @return mixed */ public function filterSubfleets($user, $flight) { $subfleets = $flight->subfleets; - /** + /* * Only allow aircraft that the user has access to in their rank */ if (setting('pireps.restrict_aircraft_to_rank', false)) { @@ -81,7 +84,7 @@ class FlightService extends Service }); } - /** + /* * Only allow aircraft that are at the current departure airport */ if (setting('pireps.only_aircraft_at_dpt_airport', false)) { @@ -103,7 +106,9 @@ class FlightService extends Service /** * Check if this flight has a duplicate already + * * @param Flight $flight + * * @return bool */ public function isFlightDuplicate(Flight $flight) @@ -140,7 +145,9 @@ class FlightService extends Service /** * Delete a flight, and all the user bids, etc associated with it + * * @param Flight $flight + * * @throws \Exception */ public function deleteFlight(Flight $flight): void @@ -152,6 +159,7 @@ class FlightService extends Service /** * Update any custom PIREP fields + * * @param Flight $flight * @param array $field_values */ @@ -164,7 +172,7 @@ class FlightService extends Service 'name' => $fv['name'], ], [ - 'value' => $fv['value'] + 'value' => $fv['value'], ] ); } @@ -172,7 +180,9 @@ class FlightService extends Service /** * Return all of the navaid points as a collection + * * @param Flight $flight + * * @return \Illuminate\Support\Collection */ public function getRoute(Flight $flight) @@ -198,30 +208,33 @@ class FlightService extends Service /** * Allow a user to bid on a flight. Check settings and all that good stuff + * * @param Flight $flight * @param User $user - * @return mixed + * * @throws \App\Exceptions\BidExists + * + * @return mixed */ public function addBid(Flight $flight, User $user) { - # Get all of the bids for this user. See if they're allowed to have multiple - # bids + // Get all of the bids for this user. See if they're allowed to have multiple + // bids $bids = Bid::where('user_id', $user->id)->get(); if ($bids->count() > 0 && setting('bids.allow_multiple_bids') === false) { throw new BidExists('User "'.$user->ident.'" already has bids, skipping'); } - # Get all of the bids for this flight + // Get all of the bids for this flight $bids = Bid::where('flight_id', $flight->id)->get(); if ($bids->count() > 0) { - # Does the flight have a bid set? + // Does the flight have a bid set? if ($flight->has_bid === false) { $flight->has_bid = true; $flight->save(); } - # Check all the bids for one of this user + // Check all the bids for one of this user foreach ($bids as $bid) { if ($bid->user_id === $user->id) { Log::info('Bid exists, user='.$user->ident.', flight='.$flight->id); @@ -229,7 +242,7 @@ class FlightService extends Service } } - # Check if the flight should be blocked off + // Check if the flight should be blocked off if (setting('bids.disable_flight_on_bid') === true) { throw new BidExists('Flight "'.$flight->ident.'" already has a bid, skipping'); } @@ -256,6 +269,7 @@ class FlightService extends Service /** * Remove a bid from a given flight + * * @param Flight $flight * @param User $user */ @@ -263,14 +277,14 @@ class FlightService extends Service { $bids = Bid::where([ 'flight_id' => $flight->id, - 'user_id' => $user->id + 'user_id' => $user->id, ])->get(); foreach ($bids as $bid) { $bid->forceDelete(); } - # Only flip the flag if there are no bids left for this flight + // Only flip the flag if there are no bids left for this flight $bids = Bid::where('flight_id', $flight->id)->get(); if ($bids->count() === 0) { $flight->has_bid = false; diff --git a/app/Services/GeoService.php b/app/Services/GeoService.php index 2ca39cca..cb8cca6b 100644 --- a/app/Services/GeoService.php +++ b/app/Services/GeoService.php @@ -18,14 +18,15 @@ use Log; /** * Class GeoService - * @package App\Services */ class GeoService extends Service { - private $acarsRepo, $navRepo; + private $acarsRepo; + private $navRepo; /** * GeoService constructor. + * * @param AcarsRepository $acarsRepo * @param NavdataRepository $navRepo */ @@ -39,10 +40,13 @@ class GeoService extends Service /** * Determine the closest set of coordinates from the starting position + * * @param array $coordStart * @param array $all_coords - * @return mixed + * * @throws \League\Geotools\Exception\InvalidArgumentException + * + * @return mixed */ public function getClosestCoords($coordStart, $all_coords) { @@ -66,10 +70,12 @@ class GeoService extends Service * Pass in a route string, with the departure/arrival airports, and the * starting coordinates. Return the route points that have been found * from the `navdata` table + * * @param $dep_icao string ICAO to ignore * @param $arr_icao string ICAO to ignore * @param $start_coords array Starting point, [x, y] * @param $route string Textual route + * * @return array */ public function getCoordsFromRoute($dep_icao, $arr_icao, $start_coords, $route): array @@ -114,12 +120,12 @@ class GeoService extends Service continue; } - # Find the point with the shortest distance + // Find the point with the shortest distance Log::info('found '.$size.' for '.$route_point); - # Get the start point and then reverse the lat/lon reference - # If the first point happens to have multiple possibilities, use - # the starting point that was passed in + // Get the start point and then reverse the lat/lon reference + // If the first point happens to have multiple possibilities, use + // the starting point that was passed in if (\count($coords) > 0) { $start_point = $coords[\count($coords) - 1]; $start_point = [$start_point->lat, $start_point->lon]; @@ -127,14 +133,14 @@ class GeoService extends Service $start_point = $start_coords; } - # Put all of the lat/lon sets into an array to pick of what's clsest - # to the starting point + // Put all of the lat/lon sets into an array to pick of what's clsest + // to the starting point $potential_coords = []; foreach ($points as $point) { $potential_coords[] = [$point->lat, $point->lon]; } - # returns an array with the closest lat/lon to start point + // returns an array with the closest lat/lon to start point $closest_coords = $this->getClosestCoords($start_point, $potential_coords); foreach ($points as $point) { if ($point->lat === $closest_coords[0] && $point->lon === $closest_coords[1]) { @@ -150,12 +156,15 @@ class GeoService extends Service /** * Determine the center point between two sets of coordinates + * * @param $latA * @param $lonA * @param $latB * @param $lonB - * @return array + * * @throws \League\Geotools\Exception\InvalidArgumentException + * + * @return array */ public function getCenter($latA, $lonA, $latB, $lonB) { @@ -168,7 +177,7 @@ class GeoService extends Service $center = [ $middlePoint->getLatitude(), - $middlePoint->getLongitude() + $middlePoint->getLongitude(), ]; return $center; @@ -176,7 +185,9 @@ class GeoService extends Service /** * Read an array/relationship of ACARS model points + * * @param Pirep $pirep + * * @return array */ public function getFeatureFromAcars(Pirep $pirep) @@ -206,7 +217,7 @@ class GeoService extends Service ]); } - /** + /* * @var $point \App\Models\Acars */ /*foreach ($pirep->acars as $point) { @@ -226,20 +237,22 @@ class GeoService extends Service 'airports' => [ 'a' => [ 'icao' => $pirep->arr_airport->icao, - 'lat' => $pirep->arr_airport->lat, - 'lon' => $pirep->arr_airport->lon, + 'lat' => $pirep->arr_airport->lat, + 'lon' => $pirep->arr_airport->lon, ], 'd' => [ 'icao' => $pirep->dpt_airport->icao, - 'lat' => $pirep->dpt_airport->lat, - 'lon' => $pirep->dpt_airport->lon, + 'lat' => $pirep->dpt_airport->lat, + 'lon' => $pirep->dpt_airport->lon, ], - ] + ], ]; } /** * Return a single feature point for the + * + * @param mixed $pireps */ public function getFeatureForLiveFlights($pireps) { @@ -269,14 +282,16 @@ class GeoService extends Service /** * Return a FeatureCollection GeoJSON object + * * @param Flight $flight + * * @return array */ public function flightGeoJson(Flight $flight): array { $route = new GeoJson(); - ## Departure Airport + //# Departure Airport $route->addPoint($flight->dpt_airport->lat, $flight->dpt_airport->lon, [ 'name' => $flight->dpt_airport->icao, 'popup' => $flight->dpt_airport->full_name, @@ -295,7 +310,7 @@ class GeoService extends Service $route->addPoint($point->lat, $point->lon, [ 'name' => $point->name, 'popup' => $point->name.' ('.$point->name.')', - 'icon' => '' + 'icon' => '', ]); } } @@ -314,7 +329,9 @@ class GeoService extends Service /** * Return a GeoJSON FeatureCollection for a PIREP + * * @param Pirep $pirep + * * @return array */ public function pirepGeoJson(Pirep $pirep) @@ -322,7 +339,7 @@ class GeoService extends Service $planned = new GeoJson(); $actual = new GeoJson(); - /** + /* * PLANNED ROUTE */ $planned->addPoint($pirep->dpt_airport->lat, $pirep->dpt_airport->lon, [ diff --git a/app/Services/ImportExport/AircraftExporter.php b/app/Services/ImportExport/AircraftExporter.php index deb55062..554e7d4e 100644 --- a/app/Services/ImportExport/AircraftExporter.php +++ b/app/Services/ImportExport/AircraftExporter.php @@ -4,13 +4,10 @@ namespace App\Services\ImportExport; use App\Interfaces\ImportExport; use App\Models\Aircraft; -use App\Models\Enums\AircraftStatus; use App\Models\Flight; /** * The flight importer can be imported or export. Operates on rows - * - * @package App\Services\Import */ class AircraftExporter extends ImportExport { @@ -26,17 +23,19 @@ class AircraftExporter extends ImportExport /** * Import a flight, parse out the different rows + * * @param Aircraft $aircraft + * * @return array */ public function export($aircraft): array { $ret = []; - foreach(self::$columns as $column) { + foreach (self::$columns as $column) { $ret[$column] = $aircraft->{$column}; } - # Modify special fields + // Modify special fields $ret['subfleet'] = $aircraft->subfleet->type; return $ret; diff --git a/app/Services/ImportExport/AircraftImporter.php b/app/Services/ImportExport/AircraftImporter.php index 2e06dee4..24d66b55 100644 --- a/app/Services/ImportExport/AircraftImporter.php +++ b/app/Services/ImportExport/AircraftImporter.php @@ -11,7 +11,6 @@ use App\Support\ICAO; /** * Import aircraft - * @package App\Services\Import */ class AircraftImporter extends ImportExport { @@ -34,7 +33,9 @@ class AircraftImporter extends ImportExport /** * Find the subfleet specified, or just create it on the fly + * * @param $type + * * @return Subfleet|\Illuminate\Database\Eloquent\Model|null|object|static */ protected function getSubfleet($type) @@ -48,8 +49,10 @@ class AircraftImporter extends ImportExport /** * Import a flight, parse out the different rows + * * @param array $row * @param int $index + * * @return bool */ public function import(array $row, $index): bool @@ -57,28 +60,28 @@ class AircraftImporter extends ImportExport $subfleet = $this->getSubfleet($row['subfleet']); $row['subfleet_id'] = $subfleet->id; - # Generate a hex code - if(!$row['hex_code']) { + // Generate a hex code + if (!$row['hex_code']) { $row['hex_code'] = ICAO::createHexCode(); } - # Set a default status + // Set a default status $row['status'] = trim($row['status']); - if($row['status'] === null || $row['status'] === '') { + if ($row['status'] === null || $row['status'] === '') { $row['status'] = AircraftStatus::ACTIVE; } - # Just set its state right now as parked + // Just set its state right now as parked $row['state'] = AircraftState::PARKED; - # Try to add or update + // Try to add or update $aircraft = Aircraft::firstOrNew([ 'registration' => $row['registration'], ], $row); try { $aircraft->save(); - } catch(\Exception $e) { + } catch (\Exception $e) { $this->errorLog('Error in row '.$index.': '.$e->getMessage()); return false; } diff --git a/app/Services/ImportExport/AirportExporter.php b/app/Services/ImportExport/AirportExporter.php index 0c1e9952..4b36f6c6 100644 --- a/app/Services/ImportExport/AirportExporter.php +++ b/app/Services/ImportExport/AirportExporter.php @@ -7,8 +7,6 @@ use App\Models\Airport; /** * The flight importer can be imported or export. Operates on rows - * - * @package App\Services\Import */ class AirportExporter extends ImportExport { @@ -24,13 +22,15 @@ class AirportExporter extends ImportExport /** * Import a flight, parse out the different rows + * * @param Airport $airport + * * @return array */ public function export($airport): array { $ret = []; - foreach(self::$columns as $column) { + foreach (self::$columns as $column) { $ret[$column] = $airport->{$column}; } diff --git a/app/Services/ImportExport/AirportImporter.php b/app/Services/ImportExport/AirportImporter.php index 7a00af1f..765f72f3 100644 --- a/app/Services/ImportExport/AirportImporter.php +++ b/app/Services/ImportExport/AirportImporter.php @@ -7,7 +7,6 @@ use App\Models\Airport; /** * Import airports - * @package App\Services\Import */ class AirportImporter extends ImportExport { @@ -35,8 +34,10 @@ class AirportImporter extends ImportExport /** * Import a flight, parse out the different rows + * * @param array $row * @param int $index + * * @return bool */ public function import(array $row, $index): bool @@ -45,7 +46,7 @@ class AirportImporter extends ImportExport $row['hub'] = get_truth_state($row['hub']); $airport = Airport::firstOrNew([ - 'id' => $row['icao'] + 'id' => $row['icao'], ], $row); try { diff --git a/app/Services/ImportExport/ExpenseExporter.php b/app/Services/ImportExport/ExpenseExporter.php index f9c95f2b..4b3ad9ed 100644 --- a/app/Services/ImportExport/ExpenseExporter.php +++ b/app/Services/ImportExport/ExpenseExporter.php @@ -5,13 +5,11 @@ namespace App\Services\ImportExport; use App\Interfaces\ImportExport; use App\Models\Aircraft; use App\Models\Airport; -use App\Models\Enums\ExpenseType; use App\Models\Expense; use App\Models\Subfleet; /** * Import expenses - * @package App\Services\Import */ class ExpenseExporter extends ImportExport { @@ -27,20 +25,22 @@ class ExpenseExporter extends ImportExport /** * Import a flight, parse out the different rows + * * @param Expense $expense + * * @return array */ public function export($expense): array { $ret = []; - foreach(self::$columns as $col) { + foreach (self::$columns as $col) { $ret[$col] = $expense->{$col}; } // Special fields - if($ret['airline']) { + if ($ret['airline']) { $ret['airline'] = $expense->airline->icao; } @@ -51,7 +51,7 @@ class ExpenseExporter extends ImportExport $ret['ref_model_id'] = ''; } else { $obj = $expense->getReferencedObject(); - if(!$obj) { // bail out + if (!$obj) { // bail out return $ret; } diff --git a/app/Services/ImportExport/ExpenseImporter.php b/app/Services/ImportExport/ExpenseImporter.php index 2f84ed34..3599e74a 100644 --- a/app/Services/ImportExport/ExpenseImporter.php +++ b/app/Services/ImportExport/ExpenseImporter.php @@ -5,14 +5,12 @@ namespace App\Services\ImportExport; use App\Interfaces\ImportExport; use App\Models\Aircraft; use App\Models\Airport; -use App\Models\Enums\ExpenseType; use App\Models\Expense; use App\Models\Subfleet; use Log; /** * Import expenses - * @package App\Services\Import */ class ExpenseImporter extends ImportExport { @@ -36,20 +34,22 @@ class ExpenseImporter extends ImportExport /** * Import a flight, parse out the different rows + * * @param array $row * @param int $index + * * @return bool */ public function import(array $row, $index): bool { - if($row['airline']) { + if ($row['airline']) { $row['airline_id'] = $this->getAirline($row['airline'])->id; } - # Figure out what this is referring to + // Figure out what this is referring to $row = $this->getRefClassInfo($row); - if(!$row['active']) { + if (!$row['active']) { $row['active'] = true; } @@ -70,7 +70,9 @@ class ExpenseImporter extends ImportExport /** * See if this expense refers to a ref_model + * * @param array $row + * * @return array */ protected function getRefClassInfo(array $row) @@ -93,19 +95,19 @@ class ExpenseImporter extends ImportExport $obj = null; if ($class === Aircraft::class) { - Log::info('Trying to import expense on aircraft, registration: ' . $id); + Log::info('Trying to import expense on aircraft, registration: '.$id); $obj = Aircraft::where('registration', $id)->first(); } elseif ($class === Airport::class) { - Log::info('Trying to import expense on airport, icao: ' . $id); + Log::info('Trying to import expense on airport, icao: '.$id); $obj = Airport::where('icao', $id)->first(); } elseif ($class === Subfleet::class) { - Log::info('Trying to import expense on subfleet, type: ' . $id); + Log::info('Trying to import expense on subfleet, type: '.$id); $obj = Subfleet::where('type', $id)->first(); } else { $this->errorLog('Unknown/unsupported Expense class: '.$class); } - if(!$obj) { + if (!$obj) { return $row; } diff --git a/app/Services/ImportExport/FareExporter.php b/app/Services/ImportExport/FareExporter.php index 25d278d4..38f42de2 100644 --- a/app/Services/ImportExport/FareExporter.php +++ b/app/Services/ImportExport/FareExporter.php @@ -7,8 +7,6 @@ use App\Models\Fare; /** * The flight importer can be imported or export. Operates on rows - * - * @package App\Services\Import */ class FareExporter extends ImportExport { @@ -24,13 +22,15 @@ class FareExporter extends ImportExport /** * Import a flight, parse out the different rows + * * @param Fare $fare + * * @return array */ public function export($fare): array { $ret = []; - foreach(self::$columns as $column) { + foreach (self::$columns as $column) { $ret[$column] = $fare->{$column}; } diff --git a/app/Services/ImportExport/FareImporter.php b/app/Services/ImportExport/FareImporter.php index 843a58b5..96e33192 100644 --- a/app/Services/ImportExport/FareImporter.php +++ b/app/Services/ImportExport/FareImporter.php @@ -7,7 +7,6 @@ use App\Models\Fare; /** * Import aircraft - * @package App\Services\Import */ class FareImporter extends ImportExport { @@ -29,20 +28,22 @@ class FareImporter extends ImportExport /** * Import a flight, parse out the different rows + * * @param array $row * @param int $index + * * @return bool */ public function import(array $row, $index): bool { - # Try to add or update + // Try to add or update $fare = Fare::firstOrNew([ 'code' => $row['code'], ], $row); try { $fare->save(); - } catch(\Exception $e) { + } catch (\Exception $e) { $this->errorLog('Error in row '.$index.': '.$e->getMessage()); return false; } diff --git a/app/Services/ImportExport/FlightExporter.php b/app/Services/ImportExport/FlightExporter.php index de53decc..4b01bc83 100644 --- a/app/Services/ImportExport/FlightExporter.php +++ b/app/Services/ImportExport/FlightExporter.php @@ -8,8 +8,6 @@ use App\Models\Flight; /** * The flight importer can be imported or export. Operates on rows - * - * @package App\Services\Import */ class FlightExporter extends ImportExport { @@ -25,23 +23,25 @@ class FlightExporter extends ImportExport /** * Import a flight, parse out the different rows + * * @param Flight $flight + * * @return array */ public function export($flight): array { $ret = []; - foreach(self::$columns as $column) { + foreach (self::$columns as $column) { $ret[$column] = $flight->{$column}; } - # Modify special fields + // Modify special fields $ret['airline'] = $ret['airline']->icao; $ret['distance'] = $ret['distance'][config('phpvms.internal_units.distance')]; $ret['dpt_airport'] = $flight->dpt_airport_id; $ret['arr_airport'] = $flight->arr_airport_id; - if($flight->alt_airport) { + if ($flight->alt_airport) { $ret['alt_airport'] = $flight->alt_airport_id; } @@ -56,14 +56,16 @@ class FlightExporter extends ImportExport /** * Return the days string + * * @param Flight $flight + * * @return string */ protected function getDays(Flight &$flight) { $days_str = ''; - if($flight->on_day(Days::MONDAY)) { + if ($flight->on_day(Days::MONDAY)) { $days_str .= '1'; } @@ -96,15 +98,17 @@ class FlightExporter extends ImportExport /** * Return any custom fares that have been made to this flight + * * @param Flight $flight + * * @return string */ protected function getFares(Flight &$flight): string { $fares = []; - foreach($flight->fares as $fare) { + foreach ($flight->fares as $fare) { $fare_export = []; - if($fare->pivot->price) { + if ($fare->pivot->price) { $fare_export['price'] = $fare->pivot->price; } @@ -124,7 +128,9 @@ class FlightExporter extends ImportExport /** * Parse all of the subfields + * * @param Flight $flight + * * @return string */ protected function getFields(Flight &$flight): string @@ -139,13 +145,15 @@ class FlightExporter extends ImportExport /** * Create the list of subfleets that are associated here + * * @param Flight $flight + * * @return string */ protected function getSubfleets(Flight &$flight): string { $subfleets = []; - foreach($flight->subfleets as $subfleet) { + foreach ($flight->subfleets as $subfleet) { $subfleets[] = $subfleet->type; } diff --git a/app/Services/ImportExport/FlightImporter.php b/app/Services/ImportExport/FlightImporter.php index 086578aa..8b8527be 100644 --- a/app/Services/ImportExport/FlightImporter.php +++ b/app/Services/ImportExport/FlightImporter.php @@ -15,8 +15,6 @@ use Log; /** * The flight importer can be imported or export. Operates on rows - * - * @package App\Services\Import */ class FlightImporter extends ImportExport { @@ -49,11 +47,9 @@ class FlightImporter extends ImportExport 'fields' => 'nullable', ]; - /** - * - */ - private $fareSvc, - $flightSvc; + private $fareSvc; + + private $flightSvc; /** * FlightImportExporter constructor. @@ -66,8 +62,10 @@ class FlightImporter extends ImportExport /** * Import a flight, parse out the different rows + * * @param array $row * @param int $index + * * @return bool */ public function import(array $row, $index): bool @@ -108,7 +106,7 @@ class FlightImporter extends ImportExport // Check for a valid value $flight_type = $row['flight_type']; - if(!array_key_exists($flight_type, FlightType::labels())) { + if (!array_key_exists($flight_type, FlightType::labels())) { $flight_type = 'J'; } @@ -139,17 +137,19 @@ class FlightImporter extends ImportExport /** * Return the mask of the days + * * @param $day_str + * * @return int|mixed */ protected function setDays($day_str) { - if(!$day_str) { + if (!$day_str) { return 0; } $days = []; - if(strpos($day_str, '1') !== false) { + if (strpos($day_str, '1') !== false) { $days[] = Days::MONDAY; } @@ -182,7 +182,9 @@ class FlightImporter extends ImportExport /** * Process the airport + * * @param $airport + * * @return \Illuminate\Database\Eloquent\Model */ protected function processAirport($airport) @@ -195,6 +197,7 @@ class FlightImporter extends ImportExport /** * Parse out all of the subfleets and associate them to the flight * The subfleet is created if it doesn't exist + * * @param Flight $flight * @param $col */ @@ -202,7 +205,7 @@ class FlightImporter extends ImportExport { $count = 0; $subfleets = $this->parseMultiColumnValues($col); - foreach($subfleets as $subfleet_type) { + foreach ($subfleets as $subfleet_type) { $subfleet = Subfleet::firstOrCreate( ['type' => $subfleet_type], ['name' => $subfleet_type] @@ -210,9 +213,9 @@ class FlightImporter extends ImportExport $subfleet->save(); - # sync + // sync $flight->subfleets()->syncWithoutDetaching([$subfleet->id]); - $count ++; + $count++; } Log::info('Subfleets added/processed: '.$count); @@ -220,6 +223,7 @@ class FlightImporter extends ImportExport /** * Parse all of the fares in the multi-format + * * @param Flight $flight * @param $col */ @@ -239,6 +243,7 @@ class FlightImporter extends ImportExport /** * Parse all of the subfields + * * @param Flight $flight * @param $col */ @@ -246,9 +251,9 @@ class FlightImporter extends ImportExport { $pass_fields = []; $fields = $this->parseMultiColumnValues($col); - foreach($fields as $field_name => $field_value) { + foreach ($fields as $field_name => $field_value) { $pass_fields[] = [ - 'name' => $field_name, + 'name' => $field_name, 'value' => $field_value, ]; } diff --git a/app/Services/ImportExport/SubfleetExporter.php b/app/Services/ImportExport/SubfleetExporter.php index d38d80e2..9967ebdd 100644 --- a/app/Services/ImportExport/SubfleetExporter.php +++ b/app/Services/ImportExport/SubfleetExporter.php @@ -3,14 +3,11 @@ namespace App\Services\ImportExport; use App\Interfaces\ImportExport; -use App\Models\Enums\FlightType; use App\Models\Flight; use App\Models\Subfleet; /** * The flight importer can be imported or export. Operates on rows - * - * @package App\Services\Import */ class SubfleetExporter extends ImportExport { @@ -26,17 +23,19 @@ class SubfleetExporter extends ImportExport /** * Import a flight, parse out the different rows + * * @param Subfleet $subfleet + * * @return array */ public function export($subfleet): array { $ret = []; - foreach(self::$columns as $column) { + foreach (self::$columns as $column) { $ret[$column] = $subfleet->{$column}; } - # Modify special fields + // Modify special fields $ret['airline'] = $subfleet->airline->icao; $ret['fares'] = $this->getFares($subfleet); @@ -45,15 +44,17 @@ class SubfleetExporter extends ImportExport /** * Return any custom fares that have been made to this flight + * * @param Subfleet $subfleet + * * @return string */ protected function getFares(Subfleet &$subfleet): string { $fares = []; - foreach($subfleet->fares as $fare) { + foreach ($subfleet->fares as $fare) { $fare_export = []; - if($fare->pivot->price) { + if ($fare->pivot->price) { $fare_export['price'] = $fare->pivot->price; } @@ -73,7 +74,9 @@ class SubfleetExporter extends ImportExport /** * Parse all of the subfields + * * @param Flight $flight + * * @return string */ protected function getFields(Flight &$flight): string @@ -88,13 +91,15 @@ class SubfleetExporter extends ImportExport /** * Create the list of subfleets that are associated here + * * @param Flight $flight + * * @return string */ protected function getSubfleets(Flight &$flight): string { $subfleets = []; - foreach($flight->subfleets as $subfleet) { + foreach ($flight->subfleets as $subfleet) { $subfleets[] = $subfleet->type; } diff --git a/app/Services/ImportExport/SubfleetImporter.php b/app/Services/ImportExport/SubfleetImporter.php index 0d817f71..7ff486eb 100644 --- a/app/Services/ImportExport/SubfleetImporter.php +++ b/app/Services/ImportExport/SubfleetImporter.php @@ -9,7 +9,6 @@ use App\Services\FareService; /** * Import subfleets - * @package App\Services\Import */ class SubfleetImporter extends ImportExport { @@ -38,8 +37,10 @@ class SubfleetImporter extends ImportExport /** * Import a flight, parse out the different rows + * * @param array $row * @param int $index + * * @return bool */ public function import(array $row, $index): bool @@ -48,12 +49,12 @@ class SubfleetImporter extends ImportExport $row['airline_id'] = $airline->id; $subfleet = Subfleet::firstOrNew([ - 'type' => $row['type'] + 'type' => $row['type'], ], $row); try { $subfleet->save(); - } catch(\Exception $e) { + } catch (\Exception $e) { $this->errorLog('Error in row '.$index.': '.$e->getMessage()); return false; } @@ -66,8 +67,9 @@ class SubfleetImporter extends ImportExport /** * Parse all of the fares in the multi-format + * * @param Subfleet $subfleet - * @param $col + * @param $col */ protected function processFares(Subfleet &$subfleet, $col): void { diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php index 50b7c876..9e74a23a 100644 --- a/app/Services/ImportService.php +++ b/app/Services/ImportService.php @@ -21,7 +21,6 @@ use Validator; /** * Class ImportService - * @package App\Services */ class ImportService extends Service { @@ -29,35 +28,42 @@ class ImportService extends Service /** * ImporterService constructor. + * * @param FlightRepository $flightRepo */ - public function __construct(FlightRepository $flightRepo) { + public function __construct(FlightRepository $flightRepo) + { $this->flightRepo = $flightRepo; } /** * Throw a validation error back up because it will automatically show * itself under the CSV file upload, and nothing special needs to be done + * * @param $error * @param $e + * * @throws ValidationException */ - protected function throwError($error, \Exception $e= null): void + protected function throwError($error, \Exception $e = null): void { Log::error($error); - if($e) { + if ($e) { Log::error($e->getMessage()); } $validator = Validator::make([], []); $validator->errors()->add('csv_file', $error); + throw new ValidationException($validator); } /** - * @param $csv_file - * @return Reader + * @param $csv_file + * * @throws ValidationException + * + * @return Reader */ public function openCsv($csv_file) { @@ -74,10 +80,13 @@ class ImportService extends Service /** * Run the actual importer, pass in one of the Import classes which implements * the ImportExport interface + * * @param $file_path * @param ImportExport $importer - * @return array + * * @throws ValidationException + * + * @return array */ protected function runImport($file_path, ImportExport $importer): array { @@ -93,7 +102,7 @@ class ImportService extends Service if ($first) { $first = false; - if($row[$first_header] !== $first_header) { + if ($row[$first_header] !== $first_header) { $this->throwError('CSV file doesn\'t seem to match import type'); } @@ -109,16 +118,16 @@ class ImportService extends Service // turn it into a collection and run some filtering $row = collect($row)->map(function ($val, $index) { $val = trim($val); - if($val === '') { - return null; + if ($val === '') { + return; } return $val; })->toArray(); - # Try to validate + // Try to validate $validator = Validator::make($row, $importer->getColumns()); - if($validator->fails()) { + if ($validator->fails()) { $errors = 'Error in row '.$offset.','.implode(';', $validator->errors()->all()); $importer->errorLog($errors); continue; @@ -132,15 +141,18 @@ class ImportService extends Service /** * Import aircraft + * * @param string $csv_file * @param bool $delete_previous - * @return mixed + * * @throws ValidationException + * + * @return mixed */ public function importAircraft($csv_file, bool $delete_previous = true) { if ($delete_previous) { - # TODO: delete airports + // TODO: delete airports } $importer = new AircraftImporter(); @@ -149,10 +161,13 @@ class ImportService extends Service /** * Import airports + * * @param string $csv_file * @param bool $delete_previous - * @return mixed + * * @throws ValidationException + * + * @return mixed */ public function importAirports($csv_file, bool $delete_previous = true) { @@ -166,10 +181,13 @@ class ImportService extends Service /** * Import expenses + * * @param string $csv_file * @param bool $delete_previous - * @return mixed + * * @throws ValidationException + * + * @return mixed */ public function importExpenses($csv_file, bool $delete_previous = true) { @@ -183,15 +201,18 @@ class ImportService extends Service /** * Import fares + * * @param string $csv_file * @param bool $delete_previous - * @return mixed + * * @throws ValidationException + * + * @return mixed */ public function importFares($csv_file, bool $delete_previous = true) { if ($delete_previous) { - # TODO: Delete all from: fares + // TODO: Delete all from: fares } $importer = new FareImporter(); @@ -200,15 +221,18 @@ class ImportService extends Service /** * Import flights + * * @param string $csv_file * @param bool $delete_previous - * @return mixed + * * @throws ValidationException + * + * @return mixed */ public function importFlights($csv_file, bool $delete_previous = true) { if ($delete_previous) { - # TODO: Delete all from: flights, flight_field_values + // TODO: Delete all from: flights, flight_field_values } $importer = new FlightImporter(); @@ -217,15 +241,18 @@ class ImportService extends Service /** * Import subfleets + * * @param string $csv_file * @param bool $delete_previous - * @return mixed + * * @throws ValidationException + * + * @return mixed */ public function importSubfleets($csv_file, bool $delete_previous = true) { if ($delete_previous) { - # TODO: Cleanup subfleet data + // TODO: Cleanup subfleet data } $importer = new SubfleetImporter(); diff --git a/app/Services/Metar/AviationWeather.php b/app/Services/Metar/AviationWeather.php index d45b57a9..092a70a5 100644 --- a/app/Services/Metar/AviationWeather.php +++ b/app/Services/Metar/AviationWeather.php @@ -8,7 +8,6 @@ use Cache; /** * Return the raw METAR string from the NOAA Aviation Weather Service - * @package App\Services\Metar */ class AviationWeather extends Metar { @@ -19,7 +18,9 @@ class AviationWeather extends Metar /** * Implement the METAR - Return the string + * * @param $icao + * * @return string */ protected function metar($icao): string @@ -29,14 +30,14 @@ class AviationWeather extends Metar config('cache.keys.WEATHER_LOOKUP.time'), function () use ($icao) { $url = static::METAR_URL.$icao; + try { $res = Http::get($url, []); $xml = simplexml_load_string($res); - if (count($xml->data->METAR->raw_text) == 0) - return ''; - else - return $xml->data->METAR->raw_text->__toString(); - + if (count($xml->data->METAR->raw_text) == 0) { + return ''; + } + return $xml->data->METAR->raw_text->__toString(); } catch (\Exception $e) { return ''; } diff --git a/app/Services/ModuleService.php b/app/Services/ModuleService.php index 9b990d7e..e57c4603 100644 --- a/app/Services/ModuleService.php +++ b/app/Services/ModuleService.php @@ -6,7 +6,6 @@ use App\Interfaces\Service; /** * Class ModuleService - * @package App\Services */ class ModuleService extends Service { @@ -17,14 +16,16 @@ class ModuleService extends Service */ protected static $frontendLinks = [ 0 => [], - 1 => [] + 1 => [], ]; /** * Add a module link in the frontend + * * @param string $title * @param string $url * @param string $icon + * @param mixed $logged_in */ public function addFrontendLink(string $title, string $url, string $icon = '', $logged_in = true) { @@ -37,6 +38,9 @@ class ModuleService extends Service /** * Get all of the frontend links + * + * @param mixed $logged_in + * * @return array */ public function getFrontendLinks($logged_in): array @@ -46,6 +50,7 @@ class ModuleService extends Service /** * Add a module link in the admin panel + * * @param string $title * @param string $url * @param string $icon @@ -55,12 +60,13 @@ class ModuleService extends Service self::$adminLinks[] = [ 'title' => $title, 'url' => $url, - 'icon' => 'pe-7s-users' + 'icon' => 'pe-7s-users', ]; } /** * Get all of the module links in the admin panel + * * @return array */ public function getAdminLinks(): array diff --git a/app/Services/PirepService.php b/app/Services/PirepService.php index cbe2780e..7e094469 100644 --- a/app/Services/PirepService.php +++ b/app/Services/PirepService.php @@ -19,9 +19,6 @@ use App\Models\Navdata; use App\Models\Pirep; use App\Models\PirepFieldValue; use App\Models\User; -use App\Repositories\AcarsRepository; -use App\Repositories\FlightRepository; -use App\Repositories\NavdataRepository; use App\Repositories\PirepRepository; use Carbon\Carbon; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -29,19 +26,19 @@ use Log; /** * Class PirepService - * @package App\Services */ class PirepService extends Service { - private $geoSvc, - $pilotSvc, - $pirepRepo; + private $geoSvc; + private $pilotSvc; + private $pirepRepo; /** * PirepService constructor. - * @param GeoService $geoSvc - * @param PirepRepository $pirepRepo - * @param UserService $pilotSvc + * + * @param GeoService $geoSvc + * @param PirepRepository $pirepRepo + * @param UserService $pilotSvc */ public function __construct( GeoService $geoSvc, @@ -56,7 +53,9 @@ class PirepService extends Service /** * Find if there are duplicates to a given PIREP. Ideally, the passed * in PIREP hasn't been saved or gone through the create() method + * * @param Pirep $pirep + * * @return bool|Pirep */ public function findDuplicate(Pirep $pirep) @@ -98,19 +97,22 @@ class PirepService extends Service * Save the route into the ACARS table with AcarsType::ROUTE * This attempts to create the route from the navdata and the route * entered into the PIREP's route field + * * @param Pirep $pirep - * @return Pirep + * * @throws \Exception + * + * @return Pirep */ public function saveRoute(Pirep $pirep): Pirep { - # Delete all the existing nav points + // Delete all the existing nav points Acars::where([ 'pirep_id' => $pirep->id, 'type' => AcarsType::ROUTE, ])->delete(); - # See if a route exists + // See if a route exists if (!filled($pirep->route)) { return $pirep; } @@ -142,7 +144,7 @@ class PirepService extends Service $acars->lon = $point->lon; $acars->save(); - ++$point_count; + $point_count++; } return $pirep; @@ -151,7 +153,7 @@ class PirepService extends Service /** * Create a new PIREP with some given fields * - * @param Pirep $pirep + * @param Pirep $pirep * @param array PirepFieldValue[] $field_values * * @return Pirep @@ -162,24 +164,24 @@ class PirepService extends Service $field_values = []; } - # Check the block times. If a block on (arrival) time isn't - # specified, then use the time that it was submitted. It won't - # be the most accurate, but that might be OK - if(!$pirep->block_on_time) { - if($pirep->submitted_at) { + // Check the block times. If a block on (arrival) time isn't + // specified, then use the time that it was submitted. It won't + // be the most accurate, but that might be OK + if (!$pirep->block_on_time) { + if ($pirep->submitted_at) { $pirep->block_on_time = $pirep->submitted_at; } else { $pirep->block_on_time = Carbon::now('UTC'); } } - # If the depart time isn't set, then try to calculate it by - # subtracting the flight time from the block_on (arrival) time - if(!$pirep->block_off_time && $pirep->flight_time > 0) { + // If the depart time isn't set, then try to calculate it by + // subtracting the flight time from the block_on (arrival) time + if (!$pirep->block_off_time && $pirep->flight_time > 0) { $pirep->block_off_time = $pirep->block_on_time->subMinutes($pirep->flight_time); } - # Check that there's a submit time + // Check that there's a submit time if (!$pirep->submitted_at) { $pirep->submitted_at = Carbon::now('UTC'); } @@ -196,12 +198,13 @@ class PirepService extends Service /** * Submit the PIREP. Figure out its default state + * * @param Pirep $pirep */ public function submit(Pirep $pirep) { - # Figure out what default state should be. Look at the default - # behavior from the rank that the pilot is assigned to + // Figure out what default state should be. Look at the default + // behavior from the rank that the pilot is assigned to $default_state = PirepState::PENDING; if ($pirep->source === PirepSource::ACARS) { if ($pirep->pilot->rank->auto_approve_acars) { @@ -220,13 +223,13 @@ class PirepService extends Service Log::info('New PIREP filed', [$pirep]); event(new PirepFiled($pirep)); - # only update the pilot last state if they are accepted + // only update the pilot last state if they are accepted if ($default_state === PirepState::ACCEPTED) { $pirep = $this->accept($pirep); $this->setPilotState($pirep->pilot, $pirep); } - # Check the user state, set them to ACTIVE if on leave + // Check the user state, set them to ACTIVE if on leave if ($pirep->user->state !== UserState::ACTIVE) { $old_state = $pirep->user->state; $pirep->user->state = UserState::ACTIVE; @@ -238,6 +241,7 @@ class PirepService extends Service /** * Update any custom PIREP fields + * * @param $pirep_id * @param array $field_values */ @@ -246,10 +250,10 @@ class PirepService extends Service foreach ($field_values as $fv) { PirepFieldValue::updateOrCreate( ['pirep_id' => $pirep_id, - 'name' => $fv['name'] + 'name' => $fv['name'], ], ['value' => $fv['value'], - 'source' => $fv['source'] + 'source' => $fv['source'], ] ); } @@ -258,6 +262,7 @@ class PirepService extends Service /** * @param Pirep $pirep * @param int $new_state + * * @return Pirep */ public function changeState(Pirep $pirep, int $new_state) @@ -268,7 +273,7 @@ class PirepService extends Service return $pirep; } - /** + /* * Move from a PENDING status into either ACCEPTED or REJECTED */ if ($pirep->state === PirepState::PENDING) { @@ -276,9 +281,8 @@ class PirepService extends Service return $this->accept($pirep); } elseif ($new_state === PirepState::REJECTED) { return $this->reject($pirep); - } else { - return $pirep; } + return $pirep; } /* * Move from a ACCEPTED to REJECTED status */ @@ -286,7 +290,7 @@ class PirepService extends Service $pirep = $this->reject($pirep); return $pirep; - } /** + } /* * Move from REJECTED to ACCEPTED */ elseif ($pirep->state === PirepState::REJECTED) { @@ -300,11 +304,12 @@ class PirepService extends Service /** * @param Pirep $pirep + * * @return Pirep */ public function accept(Pirep $pirep): Pirep { - # moving from a REJECTED state to ACCEPTED, reconcile statuses + // moving from a REJECTED state to ACCEPTED, reconcile statuses if ($pirep->state === PirepState::ACCEPTED) { return $pirep; } @@ -317,14 +322,14 @@ class PirepService extends Service $this->pilotSvc->calculatePilotRank($pilot); $pirep->pilot->refresh(); - # Change the status + // Change the status $pirep->state = PirepState::ACCEPTED; $pirep->save(); $pirep->refresh(); Log::info('PIREP '.$pirep->id.' state change to ACCEPTED'); - # Update the aircraft + // Update the aircraft $pirep->aircraft->flight_time += $pirep->flight_time; $pirep->aircraft->airport_id = $pirep->arr_airport_id; $pirep->aircraft->landing_time = $pirep->updated_at; @@ -332,7 +337,7 @@ class PirepService extends Service $pirep->refresh(); - # Any ancillary tasks before an event is dispatched + // Any ancillary tasks before an event is dispatched $this->removeBid($pirep); $this->setPilotState($pilot, $pirep); @@ -343,12 +348,13 @@ class PirepService extends Service /** * @param Pirep $pirep + * * @return Pirep */ public function reject(Pirep $pirep): Pirep { - # If this was previously ACCEPTED, then reconcile the flight hours - # that have already been counted, etc + // If this was previously ACCEPTED, then reconcile the flight hours + // that have already been counted, etc if ($pirep->state === PirepState::ACCEPTED) { $pilot = $pirep->pilot; $ft = $pirep->flight_time * -1; @@ -359,7 +365,7 @@ class PirepService extends Service $pirep->pilot->refresh(); } - # Change the status + // Change the status $pirep->state = PirepState::REJECTED; $pirep->save(); $pirep->refresh(); @@ -393,7 +399,9 @@ class PirepService extends Service /** * If the setting is enabled, remove the bid + * * @param Pirep $pirep + * * @throws \Exception */ public function removeBid(Pirep $pirep) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 9c10214c..f69b65c9 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -20,15 +20,15 @@ use Log; /** * Class UserService - * @package App\Services */ class UserService extends Service { - private $aircraftRepo, - $subfleetRepo; + private $aircraftRepo; + private $subfleetRepo; /** * UserService constructor. + * * @param AircraftRepository $aircraftRepo * @param SubfleetRepository $subfleetRepo */ @@ -43,14 +43,17 @@ class UserService extends Service /** * Register a pilot. Also attaches the initial roles * required, and then triggers the UserRegistered event + * * @param User $user User model * @param array $groups Additional groups to assign - * @return mixed + * * @throws \Exception + * + * @return mixed */ public function createPilot(User $user, array $groups = null) { - # Determine if we want to auto accept + // Determine if we want to auto accept if (setting('pilots.auto_accept') === true) { $user->state = UserState::ACTIVE; } else { @@ -59,7 +62,7 @@ class UserService extends Service $user->save(); - # Attach the user roles + // Attach the user roles $role = Role::where('name', 'user')->first(); $user->attachRole($role); @@ -70,7 +73,7 @@ class UserService extends Service } } - # Let's check their rank and where they should start + // Let's check their rank and where they should start $this->calculatePilotRank($user); $user->refresh(); @@ -82,7 +85,9 @@ class UserService extends Service /** * Return the subfleets this user is allowed access to, * based on their current rank + * * @param $user + * * @return Collection */ public function getAllowableSubfleets($user) @@ -97,8 +102,10 @@ class UserService extends Service /** * Return a bool if a user is allowed to fly the current aircraft + * * @param $user * @param $aircraft_id + * * @return bool */ public function aircraftAllowed($user, $aircraft_id) @@ -113,8 +120,10 @@ class UserService extends Service /** * Change the user's state. PENDING to ACCEPTED, etc * Send out an email + * * @param User $user * @param $old_state + * * @return User */ public function changeUserState(User $user, $old_state): User @@ -135,8 +144,10 @@ class UserService extends Service /** * Adjust the number of flights a user has. Triggers * UserStatsChanged event + * * @param User $user * @param int $count + * * @return User */ public function adjustFlightCount(User $user, int $count): User @@ -153,8 +164,10 @@ class UserService extends Service /** * Update a user's flight times + * * @param User $user * @param int $minutes + * * @return User */ public function adjustFlightTime(User $user, int $minutes): User @@ -168,24 +181,26 @@ class UserService extends Service /** * See if a pilot's rank has change. Triggers the UserStatsChanged event + * * @param User $user + * * @return User */ public function calculatePilotRank(User $user): User { $user->refresh(); - # If their current rank is one they were assigned, then - # don't change away from it automatically. + // If their current rank is one they were assigned, then + // don't change away from it automatically. if ($user->rank && $user->rank->auto_promote === false) { return $user; } $pilot_hours = new Time($user->flight_time); - # The current rank's hours are over the pilot's current hours, - # so assume that they were "placed" here by an admin so don't - # bother with updating it + // The current rank's hours are over the pilot's current hours, + // so assume that they were "placed" here by an admin so don't + // bother with updating it if ($user->rank && $user->rank->hours > $pilot_hours->hours) { return $user; } @@ -216,7 +231,9 @@ class UserService extends Service /** * Set the user's status to being on leave + * * @param User $user + * * @return User */ public function setStatusOnLeave(User $user): User @@ -233,21 +250,23 @@ class UserService extends Service /** * Recount/update all of the stats for a user + * * @param User $user + * * @return User */ public function recalculateStats(User $user): User { - # Recalc their hours + // Recalc their hours $w = [ 'user_id' => $user->id, - 'state' => PirepState::ACCEPTED, + 'state' => PirepState::ACCEPTED, ]; $flight_time = Pirep::where($w)->sum('flight_time'); $user->flight_time = $flight_time; - # Recalc the rank + // Recalc the rank $this->calculatePilotRank($user); Log::info('User '.$user->ident.' updated; rank='.$user->rank->name.'; flight_time='.$user->flight_time.' minutes'); diff --git a/app/Support/ClassLoader.php b/app/Support/ClassLoader.php index 8df7851f..829473b9 100644 --- a/app/Support/ClassLoader.php +++ b/app/Support/ClassLoader.php @@ -8,12 +8,12 @@ use Symfony\Component\ClassLoader\ClassMapGenerator; /** * Class find/load related functionality. Is used to find * the award classes right now that might be in a module - * @package App\Support */ class ClassLoader { /** * @param $path + * * @return array */ public static function getClassesInPath($path): array @@ -26,7 +26,7 @@ class ClassLoader $all_classes = array_keys(ClassMapGenerator::createMap($path)); foreach ($all_classes as $cl) { try { - $klass = new $cl; + $klass = new $cl(); } catch (\Exception $e) { Log::error('Error loading class: '.$e->getMessage()); continue; diff --git a/app/Support/Countries.php b/app/Support/Countries.php index c4c56003..bbd477b5 100644 --- a/app/Support/Countries.php +++ b/app/Support/Countries.php @@ -4,17 +4,17 @@ namespace App\Support; /** * Class Countries - * @package App\Support */ class Countries { /** * Get a select box list of all the countries + * * @return static */ public static function getSelectList() { - $countries = collect((new \League\ISO3166\ISO3166)->all()) + $countries = collect((new \League\ISO3166\ISO3166())->all()) ->mapWithKeys(function ($item, $key) { return [strtolower($item['alpha2']) => $item['name']]; }); diff --git a/app/Support/Database.php b/app/Support/Database.php index f27408dc..6accf225 100644 --- a/app/Support/Database.php +++ b/app/Support/Database.php @@ -1,16 +1,12 @@ $value) { if (strtolower($value) === 'now') { $row[$column] = static::time(); @@ -89,6 +91,7 @@ class Database DB::table($table)->insert($row); } catch (QueryException $e) { Log::error($e); + throw $e; } diff --git a/app/Support/Dates.php b/app/Support/Dates.php index 4a69cba8..890069aa 100644 --- a/app/Support/Dates.php +++ b/app/Support/Dates.php @@ -8,7 +8,9 @@ class Dates { /** * Get the list of months, given a start date + * * @param Carbon $start_date + * * @return array */ public static function getMonthsList(Carbon $start_date) @@ -28,7 +30,9 @@ class Dates /** * Return the start/end dates for a given month/year + * * @param $month YYYY-MM + * * @return array */ public static function getMonthBoundary($month) @@ -38,7 +42,7 @@ class Dates return [ "$year-$month-01", - "$year-$month-$days" + "$year-$month-$days", ]; } } diff --git a/app/Support/Http.php b/app/Support/Http.php index f5d2ba31..b5de03d0 100644 --- a/app/Support/Http.php +++ b/app/Support/Http.php @@ -6,17 +6,19 @@ use GuzzleHttp\Client; /** * Helper for HTTP stuff - * @package App\Support */ class Http { /** * Download a URI. If a file is given, it will save the downloaded * content into that file + * * @param $uri * @param array $opts - * @return string + * * @throws \GuzzleHttp\Exception\GuzzleException + * + * @return string */ public static function get($uri, array $opts) { diff --git a/app/Support/ICAO.php b/app/Support/ICAO.php index 71080394..2c20f294 100644 --- a/app/Support/ICAO.php +++ b/app/Support/ICAO.php @@ -4,14 +4,15 @@ namespace App\Support; /** * ICAO Helper Tools - * @package App\Support */ class ICAO { /** * Create a random hex code. Eventually this may follow the format in: * ICAO Aeronautical Telecommunications, Annex 10, Vol. III, chapter 9 + * * @param null $country + * * @return string */ public static function createHexCode($country = null) diff --git a/app/Support/Math.php b/app/Support/Math.php index 8e963752..bf48fa73 100644 --- a/app/Support/Math.php +++ b/app/Support/Math.php @@ -4,15 +4,16 @@ namespace App\Support; /** * Helper math - * @package App\Support */ class Math { /** * Determine from the base rate, if we want to return the overridden rate * or if the overridden rate is a percentage, then return that amount + * * @param $base_rate * @param $override_rate + * * @return float|null */ public static function applyAmountOrPercent($base_rate, $override_rate = null): ?float @@ -21,7 +22,7 @@ class Math return $base_rate; } - # Not a percentage override + // Not a percentage override if (substr_count($override_rate, '%') === 0) { return $override_rate; } @@ -31,8 +32,10 @@ class Math /** * Add/subtract a percentage to a number + * * @param $number * @param $percent + * * @return float */ public static function addPercent($number, $percent): float diff --git a/app/Support/Metar.php b/app/Support/Metar.php index 7f35a382..0a98a928 100644 --- a/app/Support/Metar.php +++ b/app/Support/Metar.php @@ -8,10 +8,6 @@ use App\Support\Units\Temperature; /** * Class Metar - * @package App\Support - * - * Modified by Nabeel S, adapted for phpVMS - * Copyright left intact below! */ /* @@ -174,12 +170,12 @@ class Metar implements \ArrayAccess 'CLR' => 'clear skies', 'NOBS' => 'no observation', // - 'FEW' => 'a few', - 'SCT' => 'scattered', - 'BKN' => 'broken sky', - 'OVC' => 'overcast sky', + 'FEW' => 'a few', + 'SCT' => 'scattered', + 'BKN' => 'broken sky', + 'OVC' => 'overcast sky', // - 'VV' => 'vertical visibility', + 'VV' => 'vertical visibility', ]; /* @@ -331,6 +327,7 @@ class Metar implements \ArrayAccess * UKDR 251830Z 00000MPS CAVOK 08/07 Q1019 3619//60 NOSIG * UBBB 251900Z 34015KT 9999 FEW013 BKN030 16/14 Q1016 88CLRD70 NOSIG * UMMS 251936Z 19002MPS 9999 SCT006 OVC026 06/05 Q1015 R31/D NOSIG RMK QBB080 OFE745 + * * @param $raw * @param bool $taf * @param bool $debug @@ -367,8 +364,10 @@ class Metar implements \ArrayAccess /** * Shortcut to call + * * @param $metar * @param string $taf + * * @return mixed */ public static function parse($metar, $taf = '') @@ -379,7 +378,9 @@ class Metar implements \ArrayAccess /** * Gets the value from result array as class property. + * * @param $parameter + * * @return mixed|null */ public function __get($parameter) @@ -387,8 +388,6 @@ class Metar implements \ArrayAccess if (isset($this->result[$parameter])) { return $this->result[$parameter]; } - - return null; } /** @@ -436,10 +435,10 @@ class Metar implements \ArrayAccess } // Finally determine if it's VFR or IFR conditions // https://www.aviationweather.gov/cva/help - if(array_key_exists('cavok', $this->result) && $this->result['cavok']) { + if (array_key_exists('cavok', $this->result) && $this->result['cavok']) { $this->result['category'] = 'VFR'; } else { - if(array_key_exists('cloud_height', $this->result) && array_key_exists('visibility', $this->result)) { + if (array_key_exists('cloud_height', $this->result) && array_key_exists('visibility', $this->result)) { if ($this->result['cloud_height']['ft'] > 3000 && $this->result['visibility']['nmi'] > 5) { $this->result['category'] = 'VFR'; } else { @@ -471,6 +470,8 @@ class Metar implements \ArrayAccess * This method formats observation date and time in the local time zone of server, * the current local time on server, and time difference since observation. $time_utc is a * UNIX timestamp for Universal Coordinated Time (Greenwich Mean Time or Zulu Time). + * + * @param mixed $time_utc */ private function set_observed_date($time_utc) { @@ -483,12 +484,13 @@ class Metar implements \ArrayAccess if ($time_diff < 91) { $this->set_result_value('observed_age', $time_diff.' '.trans_choice('widgets.weather.minago', $time_diff)); } else { - $this->set_result_value('observed_age', floor($time_diff / 60).':'.sprintf("%02d", $time_diff % 60).' '.trans_choice('widgets.weather.hrago', floor($time_diff / 60))); + $this->set_result_value('observed_age', floor($time_diff / 60).':'.sprintf('%02d', $time_diff % 60).' '.trans_choice('widgets.weather.hrago', floor($time_diff / 60))); } } /** * Sets the new value to parameter in result array. + * * @param $parameter * @param $value * @param bool $only_if_null @@ -506,6 +508,9 @@ class Metar implements \ArrayAccess /** * Sets the data group to parameter in result array. + * + * @param mixed $parameter + * @param mixed $group */ private function set_result_group($parameter, $group) { @@ -518,6 +523,7 @@ class Metar implements \ArrayAccess /** * Sets the report text to parameter in result array. + * * @param $parameter * @param $report * @param string $separator @@ -532,6 +538,8 @@ class Metar implements \ArrayAccess /** * Adds the debug text to debug information array. + * + * @param mixed $text */ private function set_debug($text) { @@ -542,6 +550,8 @@ class Metar implements \ArrayAccess /** * Adds the error text to parse errors array. + * + * @param mixed $text */ private function set_error($text) { @@ -551,8 +561,11 @@ class Metar implements \ArrayAccess // -------------------------------------------------------------------- // Methods for parsing raw parts // -------------------------------------------------------------------- + /** * Decodes TAF code if present. + * + * @param mixed $part */ private function get_taf($part) { @@ -573,6 +586,8 @@ class Metar implements \ArrayAccess /** * Decodes station code. + * + * @param mixed $part */ private function get_station($part) { @@ -589,6 +604,8 @@ class Metar implements \ArrayAccess /** * Decodes observation time. * Format is ddhhmmZ where dd = day, hh = hours, mm = minutes in UTC time. + * + * @param mixed $part */ private function get_time($part) { @@ -627,6 +644,8 @@ class Metar implements \ArrayAccess /** * Ignore station type if present. + * + * @param mixed $part */ private function get_station_type($part) { @@ -643,7 +662,9 @@ class Metar implements \ArrayAccess * Format is dddssKT where ddd = degrees from North, ss = speed, KT for knots, * or dddssGggKT where G stands for gust and gg = gust speed. (ss or gg can be a 3-digit number.) * KT can be replaced with MPH for meters per second or KMH for kilometers per hour. + * * @param $part + * * @return bool */ private function get_wind($part) @@ -724,6 +745,9 @@ class Metar implements \ArrayAccess * if visibility is limited to an integer mile plus a fraction part. * Format is mmSM for mm = statute miles, or m n/dSM for m = mile and n/d = fraction of a mile, * or just a 4-digit number nnnn (with leading zeros) for nnnn = meters. + * + * @param mixed $part + * * @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue */ @@ -792,11 +816,14 @@ class Metar implements \ArrayAccess * (if the visibility is better than 10 km, 9999 is used. 9999 means a minimum * visibility of 50 m or less), and for DD = the approximate direction of minimum and * maximum visibility is given as one of eight compass points (N, SW, ...). + * * @param $part - * @return bool + * * @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue * @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName + * + * @return bool */ private function get_visibility_min($part) { @@ -819,10 +846,13 @@ class Metar implements \ArrayAccess * Decodes runway visual range information if present. * Format is Rrrr/vvvvFT where rrr = runway number, vvvv = visibility, * and FT = the visibility in feet. + * * @param $part - * @return bool + * * @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue + * + * @return bool */ private function get_runway_vr($part) { @@ -911,7 +941,9 @@ class Metar implements \ArrayAccess * to decode all conditions. To learn more about weather condition codes, visit section * 12.6.8 - Present Weather Group of the Federal Meteorological Handbook No. 1 at * www.nws.noaa.gov/oso/oso1/oso12/fmh1/fmh1ch12.htm + * * @param $part + * * @return bool */ private function get_present_weather($part) @@ -925,10 +957,13 @@ class Metar implements \ArrayAccess * Format is SKC or CLR for clear skies, or cccnnn where ccc = 3-letter code and * nnn = height of cloud layer in hundreds of feet. 'VV' seems to be used for * very low cloud layers. + * * @param $part - * @return bool + * * @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue + * + * @return bool */ private function get_clouds($part) { @@ -942,10 +977,10 @@ class Metar implements \ArrayAccess } $observed = [ - 'amount' => null, - 'height' => null, - 'type' => null, - 'report' => null, + 'amount' => null, + 'height' => null, + 'type' => null, + 'report' => null, ]; // Clear skies or no observation @@ -984,8 +1019,8 @@ class Metar implements \ArrayAccess $report[] = 'at '.round($observed['height']['m'], 0).' meters, '.static::$cloud_type_codes[$observed['type']]; $report_ft[] = 'at '.round($observed['height']['ft'], 0).' feet, '.static::$cloud_type_codes[$observed['type']]; } else { - $report[] = 'at ' . round($observed['height']['m'], 0) . ' meters'; - $report_ft[] = 'at ' . round($observed['height']['ft'], 0) . ' feet'; + $report[] = 'at '.round($observed['height']['m'], 0).' meters'; + $report_ft[] = 'at '.round($observed['height']['ft'], 0).' feet'; } } @@ -1009,6 +1044,9 @@ class Metar implements \ArrayAccess * Format is tt/dd where tt = temperature and dd = dew point temperature. All units are * in Celsius. A 'M' preceeding the tt or dd indicates a negative temperature. Some * stations do not report dew point, so the format is tt/ or tt/XX. + * + * @param mixed $part + * * @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue */ @@ -1057,6 +1095,8 @@ class Metar implements \ArrayAccess * 1 mm Hg = 25.4 in Hg = 0.750062 hPa * 1 lb/sq in = 0.491154 in Hg = 0.014504 hPa * 1 atm = 0.33421 in Hg = 0.0009869 hPa + * + * @param mixed $part */ private function get_pressure($part) { @@ -1079,6 +1119,8 @@ class Metar implements \ArrayAccess /** * Decodes recent weather conditions if present. * Format is REww where ww = Weather phenomenon code (see get_present_weather above). + * + * @param mixed $part */ private function get_recent_weather($part) { @@ -1089,6 +1131,8 @@ class Metar implements \ArrayAccess * Decodes runways report information if present. * Format rrrECeeBB or Rrrr/ECeeBB where rr = runway number, E = deposits, * C = extent of deposit, ee = depth of deposit, BB = friction coefficient. + * + * @param mixed $part */ private function get_runways_report($part) { @@ -1195,6 +1239,8 @@ class Metar implements \ArrayAccess /** * Decodes wind shear information if present. * Format is 'WS ALL RWY' or 'WS RWYdd' where dd = Runway designator (see get_runway_vr above). + * + * @param mixed $part */ private function get_wind_shear($part) { @@ -1211,7 +1257,6 @@ class Metar implements \ArrayAccess $this->part += 2; // can skip neext parts with ALL and RWY records } // See one next part for RWYdd record elseif (isset($this->raw_parts[$this->part])) { - $r = '@^R(WY)?' // 1 .'([\d]{2}[LCR]?)$@'; // 2 @@ -1234,17 +1279,20 @@ class Metar implements \ArrayAccess /** * Decodes max and min temperature forecast information if present. + * * @param string $part - * Format TXTtTt/ddHHZ or TNTtTt/ddHHZ, where: - * TX - Indicator for Maximum temperature - * TN - Indicator for Minimum temperature - * TtTt - Temperature value in Celsius - * dd - Forecast day of month - * HH - Forecast hour, i.e. the time(hour) when the temperature is expected - * Z - Time Zone indicator, Z=GMT. - * @return bool + * Format TXTtTt/ddHHZ or TNTtTt/ddHHZ, where: + * TX - Indicator for Maximum temperature + * TN - Indicator for Minimum temperature + * TtTt - Temperature value in Celsius + * dd - Forecast day of month + * HH - Forecast hour, i.e. the time(hour) when the temperature is expected + * Z - Time Zone indicator, Z=GMT. + * * @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue + * + * @return bool */ private function get_forecast_temperature($part): bool { @@ -1262,9 +1310,9 @@ class Metar implements \ArrayAccess $temperture = new Temperature($temperature_c, 'C'); $forecast = [ - 'value' => $temperture, - 'day' => null, - 'time' => null, + 'value' => $temperture, + 'day' => null, + 'time' => null, ]; if (!empty($found[3])) { @@ -1286,6 +1334,8 @@ class Metar implements \ArrayAccess * Decodes trends information if present. * All METAR trend and TAF records is beginning at: NOSIG, BECMG, TEMP, ATDDhhmm, FMDDhhmm, * LTDDhhmm or DDhh/DDhh, where hh = hours, mm = minutes, DD = day of month. + * + * @param mixed $part */ private function get_trends($part) { @@ -1447,7 +1497,9 @@ class Metar implements \ArrayAccess /** * Get remarks information if present. * The information is everything that comes after RMK. + * * @param string $part + * * @return bool */ private function get_remarks($part): bool @@ -1460,7 +1512,7 @@ class Metar implements \ArrayAccess $remarks = []; // Get all parts after - while ($this->part < sizeof($this->raw_parts)) { + while ($this->part < count($this->raw_parts)) { if (isset($this->raw_parts[$this->part])) { $remarks[] = $this->raw_parts[$this->part]; } @@ -1477,9 +1529,11 @@ class Metar implements \ArrayAccess /** * Decodes present or recent weather conditions. + * * @param $part * @param $method * @param string $regexp_prefix + * * @return bool */ private function decode_weather($part, $method, $regexp_prefix = '') @@ -1550,8 +1604,10 @@ class Metar implements \ArrayAccess /** * Calculate Heat Index based on temperature in F and relative humidity (65 = 65%) + * * @param $temperature_f * @param $rh + * * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue * @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName */ @@ -1572,7 +1628,9 @@ class Metar implements \ArrayAccess /** * Calculate Wind Chill Temperature based on temperature in F * and wind speed in miles per hour. + * * @param $temperature_f + * * @throws \PhpUnitsOfMeasure\Exception\NonNumericValue * @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName */ @@ -1599,8 +1657,10 @@ class Metar implements \ArrayAccess * 1 knot = 1.852 km/hr = 0.514444 m/s = 1.687809 ft/s = 1.150779 mi/hr * 1 km/hr = 0.539957 knots = 0.277778 m/s = 0.911344 ft/s = 0.621371 mi/hr * 1 m/s = 1.943844 knots = 3.6 km/h = 3.28084 ft/s = 2.236936 mi/hr + * * @param $speed * @param $unit + * * @return float|null */ private function convert_speed($speed, $unit) @@ -1615,8 +1675,6 @@ class Metar implements \ArrayAccess case 'MPS': return round($speed, 2); // m/s } - - return null; } /** @@ -1625,8 +1683,10 @@ class Metar implements \ArrayAccess * 1 m = 3.28084 ft = 0.00062 mi * 1 ft = 0.3048 m = 0.00019 mi * 1 mi = 5279.99 ft = 1609.34 m + * * @param $distance * @param $unit + * * @return float|null */ private function convert_distance($distance, $unit) @@ -1640,36 +1700,40 @@ class Metar implements \ArrayAccess case 'M': return round($distance); // meters } - - return null; } /** * Convert direction degrees to compass label. + * + * @param mixed $direction */ private function convert_direction_label($direction) { if ($direction >= 0 && $direction <= 360) { return static::$direction_codes[round($direction / 22.5) % 16]; } - - return null; } /** * These methods below the implementation of the stubs for ArrayAccess + * + * @param mixed $offset */ /** * Whether a offset exists + * * @link http://php.net/manual/en/arrayaccess.offsetexists.php + * * @param mixed $offset
* An offset to check for. *
- * @return boolean true on success or false on failure. - * - *- * The return value will be casted to boolean if non-boolean was returned. + * + * @return bool true on success or false on failure. + *
+ *+ * The return value will be casted to boolean if non-boolean was returned. + * * @since 5.0.0 */ public function offsetExists($offset) @@ -1679,11 +1743,15 @@ class Metar implements \ArrayAccess /** * Offset to retrieve + * * @link http://php.net/manual/en/arrayaccess.offsetget.php + * * @param mixed $offset
* The offset to retrieve. *
+ * * @return mixed Can return all value types. + * * @since 5.0.0 */ public function offsetGet($offset) @@ -1693,14 +1761,18 @@ class Metar implements \ArrayAccess /** * Offset to set + * * @link http://php.net/manual/en/arrayaccess.offsetset.php + * * @param mixed $offset* The offset to assign the value to. *
* @param mixed $value* The value to set. *
+ * * @return void + * * @since 5.0.0 */ public function offsetSet($offset, $value) @@ -1710,11 +1782,15 @@ class Metar implements \ArrayAccess /** * Offset to unset + * * @link http://php.net/manual/en/arrayaccess.offsetunset.php + * * @param mixed $offset* The offset to unset. *
+ * * @return void + * * @since 5.0.0 */ public function offsetUnset($offset) diff --git a/app/Support/Money.php b/app/Support/Money.php index 7ac690cf..d01d3e8d 100644 --- a/app/Support/Money.php +++ b/app/Support/Money.php @@ -1,7 +1,4 @@ format('P'); if ($htmlencode) { $offset = str_replace('-', ' − ', $offset); @@ -27,7 +27,7 @@ class TimezonelistExtended extends Timezonelist $timezone = substr($timezone, strlen($continent) + 1); $timezone = str_replace('St_', 'St. ', $timezone); $timezone = str_replace('_', ' ', $timezone); - $formatted = '(GMT/UTC' . $offset . ')' . self::WHITESPACE_SEP . $timezone; + $formatted = '(GMT/UTC'.$offset.')'.self::WHITESPACE_SEP.$timezone; return $formatted; } @@ -36,41 +36,42 @@ class TimezonelistExtended extends Timezonelist * * @param string $name * @param string $selected - * @param mixed $attr - * @param bool $htmlencode + * @param mixed $attr + * @param bool $htmlencode + * * @return string */ - public function create($name, $selected='', $attr='', $htmlencode=true) + public function create($name, $selected = '', $attr = '', $htmlencode = true) { // Attributes for select element $attrSet = ''; if (!empty($attr)) { if (is_array($attr)) { foreach ($attr as $attr_name => $attr_value) { - $attrSet .= ' ' .$attr_name. '="' .$attr_value. '"'; + $attrSet .= ' '.$attr_name.'="'.$attr_value.'"'; } } else { - $attrSet = ' ' .$attr; + $attrSet = ' '.$attr; } } // start select element - $listbox = '