@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | protected array $environments = []; |
58 | 58 | |
59 | - /** |
|
59 | + /** |
|
60 | 60 | * Timezone dans lequel la tâche doit être traitée. |
61 | 61 | */ |
62 | 62 | protected ?string $timezone = null; |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | */ |
69 | 69 | protected array $attributes = []; |
70 | 70 | |
71 | - protected ContainerInterface $container; |
|
71 | + protected ContainerInterface $container; |
|
72 | 72 | |
73 | 73 | /** |
74 | 74 | * @param string $type Type de l'action en cours. |
75 | - * @param mixed $action Le contenu actuel qu'on souhaite executer. |
|
75 | + * @param mixed $action Le contenu actuel qu'on souhaite executer. |
|
76 | 76 | * |
77 | 77 | * @throws TasksException |
78 | 78 | */ |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | throw TasksException::invalidTaskType($type); |
83 | 83 | } |
84 | 84 | |
85 | - $this->container = service('container'); |
|
85 | + $this->container = service('container'); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -158,18 +158,18 @@ discard block |
||
158 | 158 | return $this; |
159 | 159 | } |
160 | 160 | |
161 | - /** |
|
162 | - * Définit le fuseau horaire pour l'exécution de la tâche. |
|
163 | - * |
|
164 | - * @param string $timezone L'identifiant du fuseau horaire à utiliser pour la tâche. |
|
165 | - * Il doit s'agir d'une chaîne de caractères PHP valide (par exemple, 'America/New_York', 'Europe/Paris'). |
|
166 | - */ |
|
167 | - public function timezone(string $timezone): self |
|
168 | - { |
|
169 | - $this->timezone = $timezone; |
|
170 | - |
|
171 | - return $this; |
|
172 | - } |
|
161 | + /** |
|
162 | + * Définit le fuseau horaire pour l'exécution de la tâche. |
|
163 | + * |
|
164 | + * @param string $timezone L'identifiant du fuseau horaire à utiliser pour la tâche. |
|
165 | + * Il doit s'agir d'une chaîne de caractères PHP valide (par exemple, 'America/New_York', 'Europe/Paris'). |
|
166 | + */ |
|
167 | + public function timezone(string $timezone): self |
|
168 | + { |
|
169 | + $this->timezone = $timezone; |
|
170 | + |
|
171 | + return $this; |
|
172 | + } |
|
173 | 173 | |
174 | 174 | /** |
175 | 175 | * Renvoie la date à laquelle cette tâche a été exécutée pour la dernière fois. |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function __construct(protected string $type, protected mixed $action, protected array $parameters = []) |
80 | 80 | { |
81 | - if (! in_array($type, $this->types, true)) { |
|
81 | + if (!in_array($type, $this->types, true)) { |
|
82 | 82 | throw TasksException::invalidTaskType($type); |
83 | 83 | } |
84 | 84 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | public function run() |
122 | 122 | { |
123 | 123 | $method = 'run' . ucfirst($this->type); |
124 | - if (! method_exists($this, $method)) { |
|
124 | + if (!method_exists($this, $method)) { |
|
125 | 125 | throw TasksException::invalidTaskType($this->type); |
126 | 126 | } |
127 | 127 | |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | $cron = service('cronExpression')->setTimezone($this->timezone); |
137 | 137 | |
138 | 138 | // Autoriser le réglage des heures pendant les tests |
139 | - if (! empty($testTime)) { |
|
139 | + if (!empty($testTime)) { |
|
140 | 140 | $cron->testTime($testTime); |
141 | 141 | } |
142 | 142 | |
143 | 143 | // Sommes-nous limités aux environnements? |
144 | - if (! empty($this->environments) && ! $this->runsInEnvironment(environment())) { |
|
144 | + if (!empty($this->environments) && !$this->runsInEnvironment(environment())) { |
|
145 | 145 | return false; |
146 | 146 | } |
147 | 147 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | */ |
249 | 249 | protected function runEvent(): bool |
250 | 250 | { |
251 | - return ! (false === service('event')->emit($this->getAction())); |
|
251 | + return !(false === service('event')->emit($this->getAction())); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -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 |
@@ -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 |