Skip to content

Commit

Permalink
QA: codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Dec 16, 2018
1 parent cbbb30e commit a6f1311
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Contributte">
<!-- Contributte Coding Standard -->
<rule ref="./vendor/ninjify/coding-standard/contributte.xml"/>
<rule ref="./vendor/ninjify/coding-standard/contributte.xml">
<exclude name="SlevomatCodingStandard.ControlStructures.RequireTernaryOperator.TernaryOperatorNotUsed"/>
<exclude name="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing.IncorrectLinesCountBeforeControlStructure"/>
<exclude name="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing.IncorrectLinesCountAfterControlStructure"/>
</rule>

<!-- Specific rules -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
Expand Down
1 change: 1 addition & 0 deletions src/Command/HelpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
| +-------------------- hour (0 - 23)
+------------------------- min (0 - 59)');
$output->writeln('');

return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions src/Command/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$table = new Table($output);
$table->setHeaders(['Key', 'Type', 'Is due', 'Cron', 'Callback']);
$dateTime = new DateTime();

foreach ($jobs as $key => $job) {
$table->addRow(self::formatRow(is_string($key) ? $key : '', $job, $dateTime));
}

$table->render();

return 0;
}

Expand All @@ -55,18 +58,21 @@ private static function formatRow(string $key, IJob $job, DateTime $dateTime): a
get_class($job),
$job->isDue($dateTime) ? 'TRUE' : 'FALSE',
];

// Expression
if ($job instanceof ExpressionJob) {
$row[] = $job->getExpression();
} else {
$row[] = 'Dynamic';
}

// Callback
if ($job instanceof CallbackJob) {
$row[] = $job->getCallback();
} else {
$row[] = 'Dynamic';
}

return $row;
}

Expand Down
1 change: 1 addition & 0 deletions src/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected function configure(): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->scheduler->run();

return 0;
}

Expand Down
1 change: 1 addition & 0 deletions src/DI/SchedulerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function loadConfiguration(): void
} else {
$job = new Statement($job);
}

$scheduler->addSetup('add', [$job, $key]);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/LockingScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function run(): void

$dateTime = new DateTime();
$jobs = $this->jobs;

foreach ($jobs as $id => $job) {
if (!$job->isDue($dateTime)) {
continue;
Expand Down
3 changes: 3 additions & 0 deletions tests/SchedulerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
final class SchedulerTest extends MockeryTest
{

/**
* @doesNotPerformAssertions
*/
public function testRun(): void
{
/** @var MockInterface|IJob $pendingJob */
Expand Down

0 comments on commit a6f1311

Please sign in to comment.