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

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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