@@ -2,40 +2,40 @@ |
||
| 2 | 2 | |
| 3 | 3 | $ignoreErrors = []; |
| 4 | 4 | $ignoreErrors[] = [ |
| 5 | - 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<cronExpression\\>, string given\\.$#', |
|
| 6 | - 'identifier' => 'argument.type', |
|
| 7 | - 'count' => 1, |
|
| 8 | - 'path' => __DIR__ . '/src/Commands/Lister.php', |
|
| 5 | + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<cronExpression\\>, string given\\.$#', |
|
| 6 | + 'identifier' => 'argument.type', |
|
| 7 | + 'count' => 1, |
|
| 8 | + 'path' => __DIR__ . '/src/Commands/Lister.php', |
|
| 9 | 9 | ]; |
| 10 | 10 | $ignoreErrors[] = [ |
| 11 | - 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<scheduler\\>, string given\\.$#', |
|
| 12 | - 'identifier' => 'argument.type', |
|
| 13 | - 'count' => 1, |
|
| 14 | - 'path' => __DIR__ . '/src/Commands/Lister.php', |
|
| 11 | + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<scheduler\\>, string given\\.$#', |
|
| 12 | + 'identifier' => 'argument.type', |
|
| 13 | + 'count' => 1, |
|
| 14 | + 'path' => __DIR__ . '/src/Commands/Lister.php', |
|
| 15 | 15 | ]; |
| 16 | 16 | $ignoreErrors[] = [ |
| 17 | - 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<scheduler\\>, string given\\.$#', |
|
| 18 | - 'identifier' => 'argument.type', |
|
| 19 | - 'count' => 1, |
|
| 20 | - 'path' => __DIR__ . '/src/Commands/Run.php', |
|
| 17 | + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<scheduler\\>, string given\\.$#', |
|
| 18 | + 'identifier' => 'argument.type', |
|
| 19 | + 'count' => 1, |
|
| 20 | + 'path' => __DIR__ . '/src/Commands/Run.php', |
|
| 21 | 21 | ]; |
| 22 | 22 | $ignoreErrors[] = [ |
| 23 | - 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<cronExpression\\>, string given\\.$#', |
|
| 24 | - 'identifier' => 'argument.type', |
|
| 25 | - 'count' => 1, |
|
| 26 | - 'path' => __DIR__ . '/src/Task.php', |
|
| 23 | + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<cronExpression\\>, string given\\.$#', |
|
| 24 | + 'identifier' => 'argument.type', |
|
| 25 | + 'count' => 1, |
|
| 26 | + 'path' => __DIR__ . '/src/Task.php', |
|
| 27 | 27 | ]; |
| 28 | 28 | $ignoreErrors[] = [ |
| 29 | - 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<httpclient\\>, string given\\.$#', |
|
| 30 | - 'identifier' => 'argument.type', |
|
| 31 | - 'count' => 1, |
|
| 32 | - 'path' => __DIR__ . '/src/Task.php', |
|
| 29 | + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<httpclient\\>, string given\\.$#', |
|
| 30 | + 'identifier' => 'argument.type', |
|
| 31 | + 'count' => 1, |
|
| 32 | + 'path' => __DIR__ . '/src/Task.php', |
|
| 33 | 33 | ]; |
| 34 | 34 | $ignoreErrors[] = [ |
| 35 | - 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<scheduler\\>, string given\\.$#', |
|
| 36 | - 'identifier' => 'argument.type', |
|
| 37 | - 'count' => 1, |
|
| 38 | - 'path' => __DIR__ . '/src/TaskRunner.php', |
|
| 35 | + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<scheduler\\>, string given\\.$#', |
|
| 36 | + 'identifier' => 'argument.type', |
|
| 37 | + 'count' => 1, |
|
| 38 | + 'path' => __DIR__ . '/src/TaskRunner.php', |
|
| 39 | 39 | ]; |
| 40 | 40 | |
| 41 | 41 | return ['parameters' => ['ignoreErrors' => $ignoreErrors]]; |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare(strict_types = 1); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | $ignoreErrors = []; |
| 4 | 4 | $ignoreErrors[] = [ |
@@ -42,4 +42,4 @@ |
||
| 42 | 42 | $reporters->add('coverage', $coverage); |
| 43 | 43 | }); |
| 44 | 44 | |
| 45 | -require_once realpath(rtrim(getcwd(), '\\/ ')).DIRECTORY_SEPARATOR.'spec'.DIRECTORY_SEPARATOR.'bootstrap.php'; |
|
| 45 | +require_once realpath(rtrim(getcwd(), '\\/ ')) . DIRECTORY_SEPARATOR . 'spec' . DIRECTORY_SEPARATOR . 'bootstrap.php'; |
|
@@ -99,7 +99,7 @@ |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Si nous ne le faisons pas correspondre, recommencez les itérations |
| 102 | - if (! $satisfied) { |
|
| 102 | + if (!$satisfied) { |
|
| 103 | 103 | $next = $this->increment($next, $position); |
| 104 | 104 | |
| 105 | 105 | continue 2; |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | * Enregistrez toutes les tâches dans cette méthode pour l'application. |
| 39 | 39 | * Appelé par TaskRunner. |
| 40 | 40 | */ |
| 41 | - 'init' => function (Scheduler $schedule) { |
|
| 41 | + 'init' => function(Scheduler $schedule) { |
|
| 42 | 42 | $schedule->command('foo:bar')->daily(); |
| 43 | 43 | |
| 44 | 44 | $schedule->shell('cp foo bar')->daily('11:00 pm'); |
@@ -144,7 +144,7 @@ |
||
| 144 | 144 | if (str_contains($time, '/')) { |
| 145 | 145 | $period = substr($time, strpos($time, '/') + 1) ?: ''; |
| 146 | 146 | |
| 147 | - if ($period === '' || ! ctype_digit($period)) { |
|
| 147 | + if ($period === '' || !ctype_digit($period)) { |
|
| 148 | 148 | throw TasksException::invalidCronExpression($this->currentExpression); |
| 149 | 149 | } |
| 150 | 150 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | protected string $timezone; |
| 29 | 29 | |
| 30 | - /** |
|
| 30 | + /** |
|
| 31 | 31 | * Le fuseau horaire global à utiliser. |
| 32 | 32 | */ |
| 33 | 33 | private string $globalTimezone; |
@@ -51,24 +51,24 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function __construct(?string $timezone = null) |
| 53 | 53 | { |
| 54 | - if (null === $globalTimezone = config('tasks.timezone')) { |
|
| 55 | - $globalTimezone = config('app.timezone'); |
|
| 56 | - } |
|
| 54 | + if (null === $globalTimezone = config('tasks.timezone')) { |
|
| 55 | + $globalTimezone = config('app.timezone'); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - $this->globalTimezone = $globalTimezone; |
|
| 58 | + $this->globalTimezone = $globalTimezone; |
|
| 59 | 59 | |
| 60 | 60 | $this->setTimezone($timezone); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Définit le fuseau horaire global pour toutes les tâches de construction. |
|
| 65 | - */ |
|
| 66 | - public function setTimezone(?string $timezone = null): self |
|
| 67 | - { |
|
| 68 | - $this->timezone = $timezone ?? $this->globalTimezone; |
|
| 63 | + /** |
|
| 64 | + * Définit le fuseau horaire global pour toutes les tâches de construction. |
|
| 65 | + */ |
|
| 66 | + public function setTimezone(?string $timezone = null): self |
|
| 67 | + { |
|
| 68 | + $this->timezone = $timezone ?? $this->globalTimezone; |
|
| 69 | 69 | |
| 70 | - return $this; |
|
| 71 | - } |
|
| 70 | + return $this; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * Vérifie si l'expression cron doit être exécutée. Permet d'utiliser un fuseau horaire personnalisé pour une tâche spécifique |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | foreach ($tasks as $task) { |
| 60 | 60 | // Si des tâches spécifiques ont été choisies, sauter l'exécution des tâches restantes. |
| 61 | - if (! empty($this->only) && ! in_array($task->name, $this->only, true)) { |
|
| 61 | + if (!empty($this->only) && !in_array($task->name, $this->only, true)) { |
|
| 62 | 62 | continue; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if (! $task->shouldRun($this->testTime) && empty($this->only)) { |
|
| 65 | + if (!$task->shouldRun($this->testTime) && empty($this->only)) { |
|
| 66 | 66 | continue; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if (! is_cli()) { |
|
| 133 | + if (!is_cli()) { |
|
| 134 | 134 | return; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Scheduler |
| 20 | 20 | { |
| 21 | - const SUNDAY = 0; |
|
| 21 | + const SUNDAY = 0; |
|
| 22 | 22 | |
| 23 | 23 | const MONDAY = 1; |
| 24 | 24 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | return $this->daily($time); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - /** |
|
| 71 | + /** |
|
| 72 | 72 | * S'exécute tous les jours à minuit, sauf si une chaîne d'heure est transmise (comme 04:08pm) |
| 73 | 73 | */ |
| 74 | 74 | public function daily(?string $time = null): self |
@@ -85,16 +85,16 @@ discard block |
||
| 85 | 85 | return $this; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - /** |
|
| 88 | + /** |
|
| 89 | 89 | * S'execute entre une temps de debut et de fin |
| 90 | 90 | */ |
| 91 | 91 | public function between(string $startTime, string $endTime): self |
| 92 | 92 | { |
| 93 | - [$minStart, $hourStart] = array_map('intval', $this->parseTime($startTime)); |
|
| 94 | - [$minEnd, $hourEnd] = array_map('intval', $this->parseTime($endTime)); |
|
| 93 | + [$minStart, $hourStart] = array_map('intval', $this->parseTime($startTime)); |
|
| 94 | + [$minEnd, $hourEnd] = array_map('intval', $this->parseTime($endTime)); |
|
| 95 | 95 | |
| 96 | - $this->betweenHours($hourStart, $hourEnd); |
|
| 97 | - $this->betweenMinutes($minStart, $minEnd); |
|
| 96 | + $this->betweenHours($hourStart, $hourEnd); |
|
| 97 | + $this->betweenMinutes($minStart, $minEnd); |
|
| 98 | 98 | |
| 99 | 99 | return $this; |
| 100 | 100 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | return $this; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - /** |
|
| 136 | + /** |
|
| 137 | 137 | * S'exécute toutes les 2 heures |
| 138 | 138 | * |
| 139 | 139 | * @param int|string|null $minute |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | return $this->everyHour(2, $minute); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - /** |
|
| 146 | + /** |
|
| 147 | 147 | * S'exécute toutes les 3 heures |
| 148 | 148 | * |
| 149 | 149 | * @param int|string|null $minute |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | return $this->everyHour(3, $minute); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - /** |
|
| 156 | + /** |
|
| 157 | 157 | * S'exécute toutes les 4 heures |
| 158 | 158 | * |
| 159 | 159 | * @param int|string|null $minute |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | return $this->everyHour(4, $minute); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - /** |
|
| 166 | + /** |
|
| 167 | 167 | * S'exécute toutes les 6 heures |
| 168 | 168 | * |
| 169 | 169 | * @param int|string|null $minute |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function everyOddHour($minute = null): self |
| 180 | 180 | { |
| 181 | - $this->expression['min'] = $minute ?? '0'; |
|
| 181 | + $this->expression['min'] = $minute ?? '0'; |
|
| 182 | 182 | $this->expression['hour'] = '1-23/2'; |
| 183 | 183 | |
| 184 | 184 | return $this; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | public function everyTenMinutes(): self |
| 261 | 261 | { |
| 262 | - return $this->everyMinute(10); |
|
| 262 | + return $this->everyMinute(10); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | return $this->monthlyOn(1, $time); |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - /** |
|
| 387 | + /** |
|
| 388 | 388 | * S'execute mensuellement à un jour et une heure donnés. |
| 389 | 389 | * |
| 390 | 390 | * @param int<1, 31> $dayOfMonth |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | { |
| 428 | 428 | $this->daily($time); |
| 429 | 429 | |
| 430 | - return $this->daysOfMonth(Date::now()->endOfMonth()->getDay()); |
|
| 430 | + return $this->daysOfMonth(Date::now()->endOfMonth()->getDay()); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -476,11 +476,11 @@ discard block |
||
| 476 | 476 | return $this->quarterlyOn(1, $time); |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - /** |
|
| 479 | + /** |
|
| 480 | 480 | * S'execute tous les trimestres à un jour et une heure donnés. |
| 481 | 481 | */ |
| 482 | 482 | public function quarterlyOn(int $dayOfQuarter = 1, ?string $time = null) |
| 483 | - { |
|
| 483 | + { |
|
| 484 | 484 | $min = $hour = 0; |
| 485 | 485 | |
| 486 | 486 | if (! empty($time)) { |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | return $this->yearlyOn(1, 1, $time); |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - /** |
|
| 507 | + /** |
|
| 508 | 508 | * S'execute chaque année à un mois, un jour et une heure donnés. |
| 509 | 509 | * |
| 510 | 510 | * @param int<1, 31> $dayOfMonth |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | { |
| 76 | 76 | $min = $hour = 0; |
| 77 | 77 | |
| 78 | - if (! empty($time)) { |
|
| 78 | + if (!empty($time)) { |
|
| 79 | 79 | [$min, $hour] = $this->parseTime($time); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function everyOddHour($minute = null): self |
| 180 | 180 | { |
| 181 | - $this->expression['min'] = $minute ?? '0'; |
|
| 181 | + $this->expression['min'] = $minute ?? '0'; |
|
| 182 | 182 | $this->expression['hour'] = '1-23/2'; |
| 183 | 183 | |
| 184 | 184 | return $this; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | public function hours($hours = []): self |
| 203 | 203 | { |
| 204 | - if (! is_array($hours)) { |
|
| 204 | + if (!is_array($hours)) { |
|
| 205 | 205 | $hours = [$hours]; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | */ |
| 296 | 296 | public function minutes($minutes = []): self |
| 297 | 297 | { |
| 298 | - if (! is_array($minutes)) { |
|
| 298 | + if (!is_array($minutes)) { |
|
| 299 | 299 | $minutes = [$minutes]; |
| 300 | 300 | } |
| 301 | 301 | |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | public function days($days): self |
| 313 | 313 | { |
| 314 | - if (! is_array($days)) { |
|
| 314 | + if (!is_array($days)) { |
|
| 315 | 315 | $days = [$days]; |
| 316 | 316 | } |
| 317 | 317 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | { |
| 394 | 394 | $min = $hour = 0; |
| 395 | 395 | |
| 396 | - if (! empty($time)) { |
|
| 396 | + if (!empty($time)) { |
|
| 397 | 397 | [$min, $hour] = $this->parseTime($time); |
| 398 | 398 | } |
| 399 | 399 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | */ |
| 412 | 412 | public function daysOfMonth($days): self |
| 413 | 413 | { |
| 414 | - if (! is_array($days)) { |
|
| 414 | + if (!is_array($days)) { |
|
| 415 | 415 | $days = [$days]; |
| 416 | 416 | } |
| 417 | 417 | |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | { |
| 484 | 484 | $min = $hour = 0; |
| 485 | 485 | |
| 486 | - if (! empty($time)) { |
|
| 486 | + if (!empty($time)) { |
|
| 487 | 487 | [$min, $hour] = $this->parseTime($time); |
| 488 | 488 | } |
| 489 | 489 | |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | { |
| 514 | 514 | $min = $hour = 0; |
| 515 | 515 | |
| 516 | - if (! empty($time)) { |
|
| 516 | + if (!empty($time)) { |
|
| 517 | 517 | [$min, $hour] = $this->parseTime($time); |
| 518 | 518 | } |
| 519 | 519 | |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | { |
| 533 | 533 | $min = $hour = 0; |
| 534 | 534 | |
| 535 | - if (! empty($time)) { |
|
| 535 | + if (!empty($time)) { |
|
| 536 | 536 | [$min, $hour] = $this->parseTime($time); |
| 537 | 537 | } |
| 538 | 538 | |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | { |
| 551 | 551 | $min = $hour = 0; |
| 552 | 552 | |
| 553 | - if (! empty($time)) { |
|
| 553 | + if (!empty($time)) { |
|
| 554 | 554 | [$min, $hour] = $this->parseTime($time); |
| 555 | 555 | } |
| 556 | 556 | |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | { |
| 569 | 569 | $min = $hour = '*'; |
| 570 | 570 | |
| 571 | - if (! empty($time)) { |
|
| 571 | + if (!empty($time)) { |
|
| 572 | 572 | [$min, $hour] = $this->parseTime($time); |
| 573 | 573 | } |
| 574 | 574 | |
@@ -25,52 +25,52 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | trait HooksTrait |
| 27 | 27 | { |
| 28 | - /** |
|
| 28 | + /** |
|
| 29 | 29 | * L'emplacement où la sortie doit être envoyée. |
| 30 | 30 | */ |
| 31 | 31 | public ?string $location = null; |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Code de sortie de la tache |
|
| 35 | - */ |
|
| 36 | - protected ?int $exitCode = null; |
|
| 33 | + /** |
|
| 34 | + * Code de sortie de la tache |
|
| 35 | + */ |
|
| 36 | + protected ?int $exitCode = null; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | + /** |
|
| 39 | 39 | * Exception levée lors de l'exécution de la tâche. |
| 40 | 40 | */ |
| 41 | - protected ?Throwable $exception = null; |
|
| 41 | + protected ?Throwable $exception = null; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | + /** |
|
| 44 | 44 | * Indique si la sortie doit être ajoutée. |
| 45 | 45 | */ |
| 46 | 46 | public bool $shouldAppendOutput = false; |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Tableau de rappels à exécuter avant l'execution de la tâche. |
| 50 | - * |
|
| 51 | - * @var list<Closure> |
|
| 50 | + * |
|
| 51 | + * @var list<Closure> |
|
| 52 | 52 | */ |
| 53 | 53 | protected array $beforeCallbacks = []; |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * Tableau de rappels à exécuter après l'execution de la tâche. |
| 57 | - * |
|
| 58 | - * @var list<Closure> |
|
| 57 | + * |
|
| 58 | + * @var list<Closure> |
|
| 59 | 59 | */ |
| 60 | 60 | protected $afterCallbacks = []; |
| 61 | 61 | |
| 62 | - /** |
|
| 62 | + /** |
|
| 63 | 63 | * Met la sortie de la tâche dans un fichier donné. |
| 64 | 64 | */ |
| 65 | 65 | public function sendOutputTo(string $location, bool $append = false): self |
| 66 | 66 | { |
| 67 | - $this->location = $location; |
|
| 68 | - $this->shouldAppendOutput = $append; |
|
| 67 | + $this->location = $location; |
|
| 68 | + $this->shouldAppendOutput = $append; |
|
| 69 | 69 | |
| 70 | 70 | return $this; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - /** |
|
| 73 | + /** |
|
| 74 | 74 | * Ajoute la sortie de la tâche à la fin d'un fichier donné. |
| 75 | 75 | */ |
| 76 | 76 | public function appendOutputTo(string $location): self |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | return $this->sendOutputTo($location, true); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - /** |
|
| 81 | + /** |
|
| 82 | 82 | * Envoi le resultat de l'execution de la tache par mail. |
| 83 | 83 | * |
| 84 | 84 | * @param array|mixed $addresses |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | }); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - /** |
|
| 127 | + /** |
|
| 128 | 128 | * Enregistre un callback à appeler avant l'opération. |
| 129 | 129 | */ |
| 130 | 130 | public function before(Closure $callback): self |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | return $this; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - /** |
|
| 155 | + /** |
|
| 156 | 156 | * Enregistre un callback à appeler si l'opération se deroulle avec succes. |
| 157 | 157 | */ |
| 158 | 158 | public function onSuccess(Closure $callback): self |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | }); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - /** |
|
| 167 | + /** |
|
| 168 | 168 | * Enregistre un callback à appeler si l'opération ne se deroulle pas correctement. |
| 169 | 169 | */ |
| 170 | 170 | public function onFailure(Closure $callback): self |
@@ -176,28 +176,28 @@ discard block |
||
| 176 | 176 | }); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * Procede a l'execution de la tache |
|
| 181 | - */ |
|
| 182 | - protected function process(ContainerInterface $container, $method): mixed |
|
| 183 | - { |
|
| 184 | - ob_start(); |
|
| 179 | + /** |
|
| 180 | + * Procede a l'execution de la tache |
|
| 181 | + */ |
|
| 182 | + protected function process(ContainerInterface $container, $method): mixed |
|
| 183 | + { |
|
| 184 | + ob_start(); |
|
| 185 | 185 | |
| 186 | - $result = $this->start($this->container, $method); |
|
| 186 | + $result = $this->start($this->container, $method); |
|
| 187 | 187 | |
| 188 | - // if (! $this->runInBackground) { |
|
| 189 | - $result = $this->finish($this->container, $result); |
|
| 188 | + // if (! $this->runInBackground) { |
|
| 189 | + $result = $this->finish($this->container, $result); |
|
| 190 | 190 | |
| 191 | - ob_end_flush(); |
|
| 191 | + ob_end_flush(); |
|
| 192 | 192 | |
| 193 | - return $result; |
|
| 193 | + return $result; |
|
| 194 | 194 | // } |
| 195 | - } |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - /** |
|
| 197 | + /** |
|
| 198 | 198 | * Demarre l'execution de la tache |
| 199 | - * |
|
| 200 | - * @return mixed Le resultat de l'execution de la tache |
|
| 199 | + * |
|
| 200 | + * @return mixed Le resultat de l'execution de la tache |
|
| 201 | 201 | * |
| 202 | 202 | * @throws Throwable |
| 203 | 203 | */ |
@@ -208,30 +208,30 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | return $this->execute($container, $runMethod); |
| 210 | 210 | } catch (Throwable $e) { |
| 211 | - $this->registerException($e); |
|
| 211 | + $this->registerException($e); |
|
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - /** |
|
| 215 | + /** |
|
| 216 | 216 | * Execute la tache. |
| 217 | - * |
|
| 218 | - * @return mixed Le resultat de l'execution de la tache |
|
| 217 | + * |
|
| 218 | + * @return mixed Le resultat de l'execution de la tache |
|
| 219 | 219 | */ |
| 220 | 220 | protected function execute(ContainerInterface $container, string $runMethod): mixed |
| 221 | 221 | { |
| 222 | - try { |
|
| 223 | - $result = $this->{$runMethod}(); |
|
| 224 | - |
|
| 225 | - if (is_int($result)) { |
|
| 226 | - $this->exitCode = $result; |
|
| 227 | - } else { |
|
| 228 | - $this->exitCode = EXIT_SUCCESS; |
|
| 229 | - } |
|
| 230 | - } catch (Throwable $e) { |
|
| 231 | - $this->registerException($e); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - return $result ?? null; |
|
| 222 | + try { |
|
| 223 | + $result = $this->{$runMethod}(); |
|
| 224 | + |
|
| 225 | + if (is_int($result)) { |
|
| 226 | + $this->exitCode = $result; |
|
| 227 | + } else { |
|
| 228 | + $this->exitCode = EXIT_SUCCESS; |
|
| 229 | + } |
|
| 230 | + } catch (Throwable $e) { |
|
| 231 | + $this->registerException($e); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + return $result ?? null; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -242,12 +242,12 @@ discard block |
||
| 242 | 242 | try { |
| 243 | 243 | $output = $this->callAfterCallbacks($container, $result); |
| 244 | 244 | } finally { |
| 245 | - if (isset($output) && $output !== '' && $this->location !== null) { |
|
| 246 | - @file_put_contents($this->location, $output, $this->shouldAppendOutput ? FILE_APPEND : 0); |
|
| 247 | - } |
|
| 245 | + if (isset($output) && $output !== '' && $this->location !== null) { |
|
| 246 | + @file_put_contents($this->location, $output, $this->shouldAppendOutput ? FILE_APPEND : 0); |
|
| 247 | + } |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - return $result; |
|
| 250 | + return $result; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | return; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - $mailer->to($addresses)->subject($this->getEmailSubject())->text($text)->send(); |
|
| 276 | + $mailer->to($addresses)->subject($this->getEmailSubject())->text($text)->send(); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | return "Sortie de la tâche planifiée pour [{$this->command}]"; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - /** |
|
| 287 | + /** |
|
| 288 | 288 | * Appelle tous les callbacks qui doivent être lancer "avant" l'exécution de la tâche. |
| 289 | 289 | */ |
| 290 | 290 | protected function callBeforeCallbacks(ContainerInterface $container): void |
@@ -294,27 +294,27 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - /** |
|
| 297 | + /** |
|
| 298 | 298 | * Appelle tous les callbacks qui doivent être lancer "apres" l'exécution de la tâche. |
| 299 | 299 | */ |
| 300 | 300 | protected function callAfterCallbacks(ContainerInterface $container, mixed $result = null): string |
| 301 | 301 | { |
| 302 | - $parameters = ['result' => $result]; |
|
| 302 | + $parameters = ['result' => $result]; |
|
| 303 | 303 | |
| 304 | - if ('' !== $output = ob_get_contents() ?: '') { |
|
| 305 | - $parameters['output'] = new Stringable($output); |
|
| 306 | - } |
|
| 304 | + if ('' !== $output = ob_get_contents() ?: '') { |
|
| 305 | + $parameters['output'] = new Stringable($output); |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | 308 | foreach ($this->afterCallbacks as $callback) { |
| 309 | 309 | $container->call($callback, $parameters); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - return $output; |
|
| 312 | + return $output; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - protected function registerException(Throwable $e) |
|
| 316 | - { |
|
| 317 | - $this->exception = $e; |
|
| 318 | - $this->exitCode = EXIT_ERROR; |
|
| 319 | - } |
|
| 315 | + protected function registerException(Throwable $e) |
|
| 316 | + { |
|
| 317 | + $this->exception = $e; |
|
| 318 | + $this->exitCode = EXIT_ERROR; |
|
| 319 | + } |
|
| 320 | 320 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $addresses = Arr::wrap($addresses); |
| 93 | 93 | |
| 94 | - return $this->then(function (MailerInterface $mailer) use ($addresses, $onlyIfOutputExists) { |
|
| 94 | + return $this->then(function(MailerInterface $mailer) use ($addresses, $onlyIfOutputExists) { |
|
| 95 | 95 | $this->emailOutput($mailer, $addresses, $onlyIfOutputExists); |
| 96 | 96 | }); |
| 97 | 97 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $addresses = Arr::wrap($addresses); |
| 121 | 121 | |
| 122 | - return $this->onFailure(function (MailerInterface $mailer) use ($addresses) { |
|
| 122 | + return $this->onFailure(function(MailerInterface $mailer) use ($addresses) { |
|
| 123 | 123 | $this->emailOutput($mailer, $addresses, false); |
| 124 | 124 | }); |
| 125 | 125 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function onSuccess(Closure $callback): self |
| 159 | 159 | { |
| 160 | - return $this->then(function (ContainerInterface $container) use ($callback) { |
|
| 160 | + return $this->then(function(ContainerInterface $container) use ($callback) { |
|
| 161 | 161 | if ($this->exitCode === EXIT_SUCCESS) { |
| 162 | 162 | $container->call($callback); |
| 163 | 163 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public function onFailure(Closure $callback): self |
| 171 | 171 | { |
| 172 | - return $this->then(function (ContainerInterface $container) use ($callback) { |
|
| 172 | + return $this->then(function(ContainerInterface $container) use ($callback) { |
|
| 173 | 173 | if ($this->exitCode !== EXIT_SUCCESS) { |
| 174 | 174 | $container->call($callback, array_filter([$this->exception])); |
| 175 | 175 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | protected function ensureOutputIsBeingCaptured() |
| 259 | 259 | { |
| 260 | 260 | if (is_null($this->output) || $this->output == $this->getDefaultOutput()) { |
| 261 | - $this->sendOutputTo(storage_path('logs/schedule-'.sha1($this->mutexName()).'.log')); |
|
| 261 | + $this->sendOutputTo(storage_path('logs/schedule-' . sha1($this->mutexName()) . '.log')); |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | |