Skip to content

Commit

Permalink
fix cs styles
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklog committed Oct 26, 2024
1 parent 2d46e9d commit 6f4e5f7
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 23 deletions.
6 changes: 6 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@
<property name="lineLimit" value="160"/>
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature">
<properties>
<property name="minParametersCount" value="2"/>
</properties>
</rule>
</ruleset>
6 changes: 4 additions & 2 deletions src/Command/CronJobDisableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ protected function configure(): void
->addArgument('job', InputArgument::REQUIRED, 'Name or id of the job to disable');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
protected function execute(
InputInterface $input,
OutputInterface $output,
): int {
$io = new CronStyle($input, $output);

$nameOrId = $input->getArgument('job');
Expand Down
6 changes: 4 additions & 2 deletions src/Command/CronJobEnableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ protected function configure(): void
->addArgument('job', InputArgument::REQUIRED, 'Name or id of the job to disable');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
protected function execute(
InputInterface $input,
OutputInterface $output,
): int {
$io = new CronStyle($input, $output);

$nameOrId = $input->getArgument('job');
Expand Down
14 changes: 10 additions & 4 deletions src/Command/CronProcessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ protected function configure(): void
$this->addArgument('cron', InputArgument::REQUIRED);
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
protected function execute(
InputInterface $input,
OutputInterface $output,
): int {
$io = new CronStyle($input, $output);

$job = $this->cronJobRepository->find($input->getArgument('cron'));
Expand Down Expand Up @@ -121,8 +123,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return $statusCode;
}

private function recordJobResult(CronJob $job, float $timeTaken, BufferedOutput $output, int $statusCode): void
{
private function recordJobResult(
CronJob $job,
float $timeTaken,
BufferedOutput $output,
int $statusCode,
): void {
$buffer = $output->isQuiet() ? null : $output->fetch();

$result = new CronJobResult(
Expand Down
8 changes: 5 additions & 3 deletions src/Command/CronRunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ public function __construct(
parent::__construct();
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
protected function execute(
InputInterface $input,
OutputInterface $output,
): int {
$style = new CronStyle($input, $output);
$now = DateTime::createFromImmutable($this->clock->now());

Expand Down Expand Up @@ -123,7 +125,7 @@ private function waitProcesses(CronJobRunningCollection $processes): void
$this->entityManager->refresh($job);
$job->decreaseRunningInstances();

if ($job->getRunningInstances() == 0) {
if ($job->getRunningInstances() === 0) {
$job->calculateNextRun();
}

Expand Down
14 changes: 10 additions & 4 deletions src/Command/CronScanCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ protected function configure(): void
->addOption('default-disabled', 'd', InputOption::VALUE_NONE, 'If set, new jobs will be disabled by default');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
protected function execute(
InputInterface $input,
OutputInterface $output,
): int {
$io = new CronStyle($input, $output);
$io->comment(sprintf('Scan for cron jobs started at %s', $this->clock->now()->format('r')));
$io->title('scanning ...');
Expand Down Expand Up @@ -123,8 +125,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::SUCCESS;
}

private function newJobFound(CronStyle $io, CronJobMetadata $metadata, bool $defaultDisabled, int $counter): void
{
private function newJobFound(
CronStyle $io,
CronJobMetadata $metadata,
bool $defaultDisabled,
int $counter,
): void {
$newJob =
CronJob::create(
$metadata->command,
Expand Down
6 changes: 4 additions & 2 deletions src/Command/CronStatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ public function __construct(
parent::__construct();
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
protected function execute(
InputInterface $input,
OutputInterface $output,
): int {
$io = new CronStyle($input, $output);

$io->title('Cron job status');
Expand Down
6 changes: 4 additions & 2 deletions src/DependencyInjection/ShapecodeCronExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
final class ShapecodeCronExtension extends ConfigurableExtension
{
/** @param array<mixed> $mergedConfig */
protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void
{
protected function loadInternal(
array $mergedConfig,
ContainerBuilder $container,
): void {
$locator = new FileLocator(__DIR__ . '/../Resources/config');
$loader = new Loader\YamlFileLoader($container, $locator);
$loader->load('services.yml');
Expand Down
6 changes: 4 additions & 2 deletions src/Entity/CronJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ public function __construct(
$this->calculateNextRun();
}

public static function create(string $command, string $period): self
{
public static function create(
string $command,
string $period,
): self {
return new self($command, $period);
}

Expand Down
6 changes: 4 additions & 2 deletions src/Repository/CronJobRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ public function __construct(ManagerRegistry $registry)
parent::__construct($registry, CronJob::class);
}

public function findOneByCommand(string $command, int $number = 1): CronJob|null
{
public function findOneByCommand(
string $command,
int $number = 1,
): CronJob|null {
return $this->findOneBy([
'command' => $command,
'number' => $number,
Expand Down

0 comments on commit 6f4e5f7

Please sign in to comment.