Apply fixes from StyleCI

This commit is contained in:
Nabeel Shahzad
2018-08-26 16:40:04 +00:00
committed by StyleCI Bot
parent 20f46adbc4
commit 9596d88b48
407 changed files with 4032 additions and 3286 deletions

View File

@@ -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()
{

View File

@@ -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;

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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);

View File

@@ -1,7 +1,4 @@
<?php
/**
*
*/
namespace App\Console\Commands;
@@ -10,7 +7,6 @@ use App\Services\ImportService;
/**
* Class ImportCsv
* @package App\Console\Commands
*/
class ImportCsv extends Command
{
@@ -21,6 +17,7 @@ class ImportCsv extends Command
/**
* Import constructor.
*
* @param ImportService $importer
*/
public function __construct(ImportService $importer)
@@ -30,8 +27,9 @@ class ImportCsv extends Command
}
/**
* @return mixed|void
* @throws \Illuminate\Validation\ValidationException
*
* @return mixed|void
*/
public function handle()
{
@@ -48,7 +46,7 @@ class ImportCsv extends Command
$status = $this->importer->importSubfleets($file);
}
foreach($status['success'] as $line) {
foreach ($status['success'] as $line) {
$this->info($line);
}

View File

@@ -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);

View File

@@ -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++;

View File

@@ -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'));

View File

@@ -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";
}
}

View File

@@ -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;
}
}

View File

@@ -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()