Code style fixes.

This commit is contained in:
Dmitry Khomutov 2017-12-05 20:57:53 +07:00
commit e59e4a397f
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
10 changed files with 59 additions and 43 deletions

View file

@ -13,7 +13,7 @@ use Symfony\Component\Console\Question\Question;
/**
* Create admin command - creates an admin user
*
*
* @author Wogan May (@woganmay)
*/
class CreateAdminCommand extends Command
@ -38,9 +38,9 @@ class CreateAdminCommand extends Command
$this
->setName('php-censor:create-admin')
->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin name')
->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin name')
->addOption('admin-password', null, InputOption::VALUE_OPTIONAL, 'Admin password')
->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'Admin email')
->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'Admin email')
->setDescription('Create an admin user');
}

View file

@ -47,12 +47,14 @@ class CreateBuildCommand extends Command
{
$this
->setName('php-censor:create-build')
->setDescription('Create a build for a project')
->addArgument('projectId', InputArgument::REQUIRED, 'A project ID')
->addOption('commit', null, InputOption::VALUE_OPTIONAL, 'Commit ID to build')
->addOption('branch', null, InputOption::VALUE_OPTIONAL, 'Branch to build')
->addOption('email', null, InputOption::VALUE_OPTIONAL, 'Committer email')
->addOption('message', null, InputOption::VALUE_OPTIONAL, 'Commit message');
->addOption('message', null, InputOption::VALUE_OPTIONAL, 'Commit message')
->setDescription('Create a build for a project');
}
/**

View file

@ -37,19 +37,19 @@ class InstallCommand extends Command
$this
->setName('php-censor:install')
->addOption('url', null, InputOption::VALUE_OPTIONAL, 'PHP Censor installation URL')
->addOption('db-type', null, InputOption::VALUE_OPTIONAL, 'Database type')
->addOption('db-host', null, InputOption::VALUE_OPTIONAL, 'Database host')
->addOption('db-port', null, InputOption::VALUE_OPTIONAL, 'Database port')
->addOption('db-name', null, InputOption::VALUE_OPTIONAL, 'Database name')
->addOption('db-user', null, InputOption::VALUE_OPTIONAL, 'Database user')
->addOption('db-password', null, InputOption::VALUE_OPTIONAL, 'Database password')
->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin name')
->addOption('admin-password', null, InputOption::VALUE_OPTIONAL, 'Admin password')
->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'Admin email')
->addOption('queue-use', null, InputOption::VALUE_OPTIONAL, 'Don\'t ask for queue details', true)
->addOption('queue-host', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname')
->addOption('queue-name', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue name')
->addOption('url', null, InputOption::VALUE_OPTIONAL, 'PHP Censor installation URL')
->addOption('db-type', null, InputOption::VALUE_OPTIONAL, 'Database type')
->addOption('db-host', null, InputOption::VALUE_OPTIONAL, 'Database host')
->addOption('db-port', null, InputOption::VALUE_OPTIONAL, 'Database port')
->addOption('db-name', null, InputOption::VALUE_OPTIONAL, 'Database name')
->addOption('db-user', null, InputOption::VALUE_OPTIONAL, 'Database user')
->addOption('db-password', null, InputOption::VALUE_OPTIONAL, 'Database password')
->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin name')
->addOption('admin-password', null, InputOption::VALUE_OPTIONAL, 'Admin password')
->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'Admin email')
->addOption('queue-use', null, InputOption::VALUE_OPTIONAL, 'Don\'t ask for queue details', true)
->addOption('queue-host', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname')
->addOption('queue-name', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue name')
->addOption('config-from-file', null, InputOption::VALUE_OPTIONAL, 'Take config from file and ignore options', false)
->setDescription('Install PHP Censor');
@ -467,7 +467,6 @@ class InstallCommand extends Command
unset($pdo);
return true;
} catch (Exception $ex) {
$output->writeln('<error>PHP Censor could not connect to database with the details provided. Please try again.</error>');
$output->writeln('<error>' . $ex->getMessage() . '</error>');

View file

@ -18,7 +18,7 @@ use PHPCensor\Model\Build;
/**
* Run console command - Runs any pending builds.
*
*
* @author Dan Cryer <dan@block8.co.uk>
*/
class RunCommand extends Command
@ -52,8 +52,10 @@ class RunCommand extends Command
{
$this
->setName('php-censor:run-builds')
->setDescription('Run all pending PHP Censor builds')
->addOption('debug', null, null, 'Run PHP Censor in debug mode');
->addOption('debug', null, null, 'Run PHP Censor in debug mode')
->setDescription('Run all pending PHP Censor builds');
}
/**
@ -81,7 +83,7 @@ class RunCommand extends Command
$this->logger->pushProcessor(new LoggedBuildContextTidier());
$this->logger->addInfo('Finding builds to process');
/** @var BuildStore $buildStore */
$buildStore = Factory::getStore('Build');
$result = $buildStore->getByStatus(Build::STATUS_PENDING, $this->maxBuilds);

View file

@ -55,8 +55,10 @@ class ScheduleBuildCommand extends Command
{
$this
->setName('php-censor:schedule-build')
->setDescription('Schedules a build for active projects which have not been ran by X days')
->addArgument('days', InputArgument::REQUIRED, 'Since specified days');
->addArgument('days', InputArgument::REQUIRED, 'Since specified days')
->setDescription('Schedules a build for active projects which have not been ran by X days');
}
/**

View file

@ -41,8 +41,10 @@ class WorkerCommand extends Command
{
$this
->setName('php-censor:worker')
->setDescription('Runs the PHP Censor build worker.')
->addOption('debug', null, null, 'Run PHP Censor in Debug Mode');
->addOption('debug', null, null, 'Run PHP Censor in Debug Mode')
->setDescription('Runs the PHP Censor build worker.');
}
protected function execute(InputInterface $input, OutputInterface $output)

View file

@ -274,8 +274,8 @@ class BuildStore extends Store
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$projects = [];
$latest = [];
foreach($res as $item) {
$latest = [];
foreach ($res as $item) {
$project_id = $item['project_id'];
$environment = $item['environment'];
if (empty($projects[$project_id])) {
@ -312,11 +312,13 @@ class BuildStore extends Store
$projects[$project_id][$environment]['failed'] = $build;
}
}
foreach($projects as $idx => $project) {
foreach ($projects as $idx => $project) {
$projects[$idx] = array_filter($project, function($val) {
return ($val['latest'][0]->getStatus() != Build::STATUS_SUCCESS);
});
}
$projects = array_filter($projects);
return ['projects' => $projects, 'latest' => $latest];