-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Task.php
769 lines (674 loc) · 24.7 KB
/
Task.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
<?php
/*
* This file is part of the zenstruck/schedule-bundle package.
*
* (c) Kevin Bond <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Zenstruck\ScheduleBundle\Schedule;
use Symfony\Component\Mime\Address;
use Zenstruck\ScheduleBundle\Schedule\Exception\SkipTask;
use Zenstruck\ScheduleBundle\Schedule\Extension\BetweenTimeExtension;
use Zenstruck\ScheduleBundle\Schedule\Extension\CallbackExtension;
use Zenstruck\ScheduleBundle\Schedule\Extension\EmailExtension;
use Zenstruck\ScheduleBundle\Schedule\Extension\NotifierExtension;
use Zenstruck\ScheduleBundle\Schedule\Extension\PingExtension;
use Zenstruck\ScheduleBundle\Schedule\Extension\SingleServerExtension;
use Zenstruck\ScheduleBundle\Schedule\Extension\WithoutOverlappingExtension;
use Zenstruck\ScheduleBundle\Schedule\Task\TaskRunContext;
/**
* @author Taylor Otwell <[email protected]>
* @author Kevin Bond <[email protected]>
*/
abstract class Task
{
use HasExtensions;
public const FILTER = 'Filter Task';
public const BEFORE = 'Before Task';
public const AFTER = 'After Task';
public const SUCCESS = 'On Task Success';
public const FAILURE = 'On Task Failure';
private const DEFAULT_EXPRESSION = '* * * * *';
private string $expression = self::DEFAULT_EXPRESSION;
private ?\DateTimeZone $timezone = null;
private ?string $customId = null;
public function __construct(private string $description)
{
}
final public function __toString(): string
{
if ($this->customId) {
return "{$this->getType()} `{$this->customId}`: {$this->getDescription()}";
}
return "{$this->getType()}: {$this->getDescription()}";
}
public function getType(): string
{
return (new \ReflectionClass($this))->getShortName();
}
final public function getId(): string
{
return $this->customId ?? \sha1(static::class.$this->getExpression().$this->getDescription());
}
final public function hasCustomIdentifier(): bool
{
return null !== $this->customId;
}
final public function getDescription(): string
{
return $this->description;
}
/**
* @return array<string,string>
*/
public function getContext(): array
{
return [];
}
final public function getExpression(): CronExpression
{
return new CronExpression($this->expression, $this->getDescription());
}
final public function getTimezone(): ?\DateTimeZone
{
return $this->timezone;
}
final public function getNextRun(): \DateTimeInterface
{
return $this->getExpression()->getNextRun($this->getTimezoneValue());
}
final public function isDue(\DateTimeInterface $timestamp): bool
{
return $this->getExpression()->isDue($timestamp, $this->getTimezoneValue());
}
/**
* Set a unique identifier for this task.
*/
final public function identifiedBy(string $id): self
{
$this->customId = $id;
return $this;
}
/**
* Set a unique description for this task.
*/
final public function description(string $description): self
{
$this->description = $description;
return $this;
}
/**
* The timezone this task should run in.
*
* @param string|\DateTimeZone $value
*/
final public function timezone($value): self
{
if (!$value instanceof \DateTimeZone) {
$value = new \DateTimeZone($value);
}
$this->timezone = $value;
return $this;
}
/**
* Prevent task from running if callback throws \Zenstruck\ScheduleBundle\Schedule\Exception\SkipTask.
*
* @param callable $callback Receives an instance of \Zenstruck\ScheduleBundle\Schedule\Task\TaskRunContext
*/
final public function filter(callable $callback, ?string $description = null): self
{
return $this->addExtension(CallbackExtension::taskFilter($callback, $description));
}
/**
* Only run task if true.
*
* @param bool|callable $callback bool: skip if false, callable: skip if return value is false
* callable receives an instance of \Zenstruck\ScheduleBundle\Schedule\Task\TaskRunContext
*/
final public function when(string $description, $callback): self
{
$callback = \is_callable($callback) ? $callback : fn() => (bool) $callback;
return $this->filter(function(TaskRunContext $context) use ($callback, $description) {
if (!$callback($context)) {
throw new SkipTask($description);
}
});
}
/**
* Skip task if true.
*
* @param bool|callable $callback bool: skip if true, callable: skip if return value is true
* callable receives an instance of \Zenstruck\ScheduleBundle\Schedule\Task\TaskRunContext
*/
final public function skip(string $description, $callback): self
{
$callback = \is_callable($callback) ? $callback : fn() => (bool) $callback;
return $this->filter(function(TaskRunContext $context) use ($callback, $description) {
if ($callback($context)) {
throw new SkipTask($description);
}
});
}
/**
* Execute callback before task runs.
*
* @param callable $callback Receives an instance of \Zenstruck\ScheduleBundle\Schedule\Task\TaskRunContext
*/
final public function before(callable $callback, ?string $description = null): self
{
return $this->addExtension(CallbackExtension::taskBefore($callback, $description));
}
/**
* Execute callback after task has run (will not execute if skipped).
*
* @param callable $callback Receives an instance of \Zenstruck\ScheduleBundle\Schedule\Task\TaskRunContext
*/
final public function after(callable $callback, ?string $description = null): self
{
return $this->addExtension(CallbackExtension::taskAfter($callback, $description));
}
/**
* Alias for after().
*/
final public function then(callable $callback): self
{
return $this->after($callback);
}
/**
* Execute callback if task was successful (will not execute if skipped).
*
* @param callable $callback Receives an instance of \Zenstruck\ScheduleBundle\Schedule\Task\TaskRunContext
*/
final public function onSuccess(callable $callback, ?string $description = null): self
{
return $this->addExtension(CallbackExtension::taskSuccess($callback, $description));
}
/**
* Execute callback if task failed (will not execute if skipped).
*
* @param callable $callback Receives an instance of \Zenstruck\ScheduleBundle\Schedule\Task\TaskRunContext
*/
final public function onFailure(callable $callback, ?string $description = null): self
{
return $this->addExtension(CallbackExtension::taskFailure($callback, $description));
}
/**
* Ping a webhook before task runs (will not ping if task was skipped).
* If you want to control the HttpClient used, configure `zenstruck_schedule.http_client`.
*
* @param array $options See HttpClientInterface::OPTIONS_DEFAULTS
*/
final public function pingBefore(string $url, string $method = 'GET', array $options = []): self
{
return $this->addExtension(PingExtension::taskBefore($url, $method, $options));
}
/**
* Ping a webhook after task has run (will not ping if task was skipped).
* If you want to control the HttpClient used, configure `zenstruck_schedule.http_client`.
*
* @param array $options See HttpClientInterface::OPTIONS_DEFAULTS
*/
final public function pingAfter(string $url, string $method = 'GET', array $options = []): self
{
return $this->addExtension(PingExtension::taskAfter($url, $method, $options));
}
/**
* Alias for pingAfter().
*/
final public function thenPing(string $url, string $method = 'GET', array $options = []): self
{
return $this->pingAfter($url, $method, $options);
}
/**
* Ping a webhook if task was successful (will not ping if task was skipped).
* If you want to control the HttpClient used, configure `zenstruck_schedule.http_client`.
*
* @param array $options See HttpClientInterface::OPTIONS_DEFAULTS
*/
final public function pingOnSuccess(string $url, string $method = 'GET', array $options = []): self
{
return $this->addExtension(PingExtension::taskSuccess($url, $method, $options));
}
/**
* Ping a webhook if task failed (will not ping if task was skipped).
* If you want to control the HttpClient used, configure `zenstruck_schedule.http_client`.
*
* @param array $options See HttpClientInterface::OPTIONS_DEFAULTS
*/
final public function pingOnFailure(string $url, string $method = 'GET', array $options = []): self
{
return $this->addExtension(PingExtension::taskFailure($url, $method, $options));
}
/**
* Email task detail after run (on success or failure, not if skipped).
* Be sure to configure `zenstruck_schedule.mailer`.
*
* @param string|Address|string[]|Address[]|null $to Email address(es)
* @param callable|null $callback Add your own headers etc
* Receives an instance of \Symfony\Component\Mime\Email
*/
final public function emailAfter($to = null, ?string $subject = null, ?callable $callback = null): self
{
return $this->addExtension(EmailExtension::taskAfter($to, $subject, $callback));
}
/**
* Send notification with task detail after run (on success or failure, not if skipped).
* Be sure to configure `zenstruck_schedule.notifier`.
*
* @param string|string[] $channel Channel to send notification to (E.G "chat/slack")
* @param string|null $email Email address for email notification
* @param string|null $phone Phone number for SMS notification
* @param callable|null $callback Customise the notification
* Receives an instance of \Symfony\Component\Notification\Notification
*/
final public function notifyAfter($channel = null, ?string $email = null, ?string $phone = null, ?string $subject = null, ?callable $callback = null): self
{
return $this->addExtension(NotifierExtension::taskAfter($channel, $email, $phone, $subject, $callback));
}
/**
* Alias for emailAfter().
*
* @param string|Address|string[]|Address[]|null $to Email address(es)
*/
final public function thenEmail($to = null, ?string $subject = null, ?callable $callback = null): self
{
return $this->emailAfter($to, $subject, $callback);
}
/**
* Alias for notifyAfter().
*
* @param string|string[] $channel Channel to send notification to (E.G "chat/slack")
* @param string|null $email Email address for email notification
* @param string|null $phone Phone number for SMS notification
* @param callable|null $callback Customise the notification
* Receives an instance of \Symfony\Component\Notification\Notification
*/
final public function thenNotify($channel = null, ?string $email = null, ?string $phone = null, ?string $subject = null, ?callable $callback = null): self
{
return $this->notifyAfter($channel, $email, $phone, $subject, $callback);
}
/**
* Email task/failure details if failed (not if skipped).
* Be sure to configure `zenstruck_schedule.mailer`.
*
* @param string|Address|string[]|Address[]|null $to Email address(es)
* @param callable|null $callback Add your own headers etc
* Receives an instance of \Symfony\Component\Mime\Email
*/
final public function emailOnFailure($to = null, ?string $subject = null, ?callable $callback = null): self
{
return $this->addExtension(EmailExtension::taskFailure($to, $subject, $callback));
}
/**
* Send notification with task/failure details if failed (not if skipped).
* Be sure to configure `zenstruck_schedule.notifier`.
*
* @param string|string[] $channel Channel to send notification to (E.G "chat/slack")
* @param string|null $email Email address for email notification
* @param string|null $phone Phone number for SMS notification
* @param callable|null $callback Customise the notification
* Receives an instance of \Symfony\Component\Notification\Notification
*/
final public function notifyOnFailure($channel = null, ?string $email = null, ?string $phone = null, ?string $subject = null, ?callable $callback = null): self
{
return $this->addExtension(NotifierExtension::taskFailure($channel, $email, $phone, $subject, $callback));
}
/**
* Prevent task from running if still running from previous run.
*
* @param int $ttl Maximum expected lock duration in seconds
*/
final public function withoutOverlapping(int $ttl = WithoutOverlappingExtension::DEFAULT_TTL): self
{
return $this->addExtension(new WithoutOverlappingExtension($ttl));
}
/**
* Restrict running of schedule to a single server.
* Be sure to configure `zenstruck_schedule.single_server_lock_factory`.
*
* @param int $ttl Maximum expected lock duration in seconds
*/
final public function onSingleServer(int $ttl = SingleServerExtension::DEFAULT_TTL): self
{
return $this->addExtension(new SingleServerExtension($ttl));
}
/**
* Only run between given times.
*
* @param string $startTime "HH:MM" (ie "09:00")
* @param string $endTime "HH:MM" (ie "14:30")
* @param bool $inclusive Whether to include the start and end time
*/
final public function onlyBetween(string $startTime, string $endTime, bool $inclusive = true): self
{
return $this->addExtension(BetweenTimeExtension::whenWithin($startTime, $endTime, $inclusive));
}
/**
* Skip when between given times.
*
* @param string $startTime "HH:MM" (ie "09:00")
* @param string $endTime "HH:MM" (ie "14:30")
* @param bool $inclusive Whether to include the start and end time
*/
final public function unlessBetween(string $startTime, string $endTime, bool $inclusive = true): self
{
return $this->addExtension(BetweenTimeExtension::unlessWithin($startTime, $endTime, $inclusive));
}
/**
* Set your own cron expression (ie "15 3 * * 1,4").
*/
final public function cron(string $expression): self
{
$this->expression = $expression;
return $this;
}
/**
* Resets the expression to "* * * * *".
*/
final public function everyMinute(): self
{
return $this->cron(self::DEFAULT_EXPRESSION);
}
/**
* Resets the expression to "<*>/5 * * * *".
*/
final public function everyFiveMinutes(): self
{
return $this->cron('*/5 * * * *');
}
/**
* Resets the expression to "<*>/10 * * * *".
*/
final public function everyTenMinutes(): self
{
return $this->cron('*/10 * * * *');
}
/**
* Resets the expression to "<*>/15 * * * *".
*/
final public function everyFifteenMinutes(): self
{
return $this->cron('*/15 * * * *');
}
/**
* Resets the expression to "<*>/20 * * * *".
*/
final public function everyTwentyMinutes(): self
{
return $this->cron('*/20 * * * *');
}
/**
* Resets the expression to "0,30 * * * *".
*/
final public function everyThirtyMinutes(): self
{
return $this->cron('0,30 * * * *');
}
/**
* Resets the expression to "0 * * * *".
*/
final public function hourly(): self
{
return $this->cron('0 * * * *');
}
/**
* Resets the expression to "X * * * *" with X being the passed minute(s).
*
* @param int|string $minute Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (20/2)
* @param int|string ...$minutes Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (20/2)
*/
final public function hourlyAt($minute, ...$minutes): self
{
return $this->hourly()->minutes($minute, ...$minutes);
}
/**
* Resets the expression to "0 0 * * *".
*/
final public function daily(): self
{
return $this->cron('0 0 * * *');
}
/**
* Resets the expression to "0 X * * *" with X being the passed hour(s).
*
* @param int|string $hour Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (1-5/2)
* @param int|string ...$hours Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (1-5/2)
*/
final public function dailyOn($hour, ...$hours): self
{
return $this->daily()->hours($hour, ...$hours);
}
/**
* Resets the expression to "0 X-Y * * *" with X and Y being the passed start and end hours.
*
* @param int $firstHour 0-23
* @param int $secondHour 0-23
*/
final public function dailyBetween(int $firstHour, int $secondHour): self
{
return $this->daily()->hours("{$firstHour}-{$secondHour}");
}
/**
* Resets the expression to "0 X,Y * * *" with X and Y being the passed hours.
*
* @param int $firstHour 0-23
* @param int $secondHour 0-23
*/
final public function twiceDaily(int $firstHour = 1, int $secondHour = 13): self
{
return $this->dailyOn($firstHour, $secondHour);
}
/**
* Shortcut for ->daily()->at($time).
*
* @param string $time Integer for just the hour (ie 2) or "HH:MM" for hour and minute (ie "14:30")
*/
final public function dailyAt(string $time): self
{
return $this->daily()->at($time);
}
/**
* Resets the expression to "0 0 * * 0".
*/
final public function weekly(): self
{
return $this->cron('0 0 * * 0');
}
/**
* Resets the expression to "0 0 * * X" with X being the passed day(s) of week.
*
* @param int|string $day Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (1-5/2)
* @param int|string ...$days Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (1-5/2)
*/
final public function weeklyOn($day, ...$days): self
{
return $this->weekly()->daysOfWeek($day, ...$days);
}
/**
* Resets the expression to "0 0 1 * *".
*/
final public function monthly(): self
{
return $this->cron('0 0 1 * *');
}
/**
* Resets the expression to "0 0 X * *" with X being the passed day(s) of month.
*
* @param int|string $day Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (20/2)
* @param int|string ...$days Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (20/2)
*/
final public function monthlyOn($day, ...$days): self
{
return $this->monthly()->daysOfMonth($day, ...$days);
}
/**
* Resets the expression to "0 0 X,Y * *" with X and Y being the passed days of the month.
*
* @param int $firstDay 1-31
* @param int $secondDay 1-31
*/
final public function twiceMonthly(int $firstDay = 1, int $secondDay = 16): self
{
return $this->monthlyOn($firstDay, $secondDay);
}
/**
* Resets the expression to "0 0 1 1 *".
*/
final public function yearly(): self
{
return $this->cron('0 0 1 1 *');
}
/**
* Resets the expression to "0 0 1 1-12/3 *".
*/
final public function quarterly(): self
{
return $this->cron('0 0 1 */3 *');
}
/**
* Set just the "minute" field.
*
* @param int|string $minute Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (20/2)
* @param int|string ...$minutes Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (20/2)
*/
final public function minutes($minute, ...$minutes): self
{
return $this->spliceIntoPosition(CronExpression::MINUTE, $minute, ...$minutes);
}
/**
* Set just the "hour" field.
*
* @param int|string $hour Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (20/2)
* @param int|string ...$hours Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (20/2)
*/
final public function hours($hour, ...$hours): self
{
return $this->spliceIntoPosition(CronExpression::HOUR, $hour, ...$hours);
}
/**
* Set just the "day of month" field.
*
* @param int|string $day Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (20/2)
* @param int|string ...$days Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (20/2)
*/
final public function daysOfMonth($day, ...$days): self
{
return $this->spliceIntoPosition(CronExpression::DOM, $day, ...$days);
}
/**
* Set just the "month" field.
*
* @param int|string $month Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (1-12/3)
* @param int|string ...$months Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (1-12/3)
*/
final public function months($month, ...$months): self
{
return $this->spliceIntoPosition(CronExpression::MONTH, $month, ...$months);
}
/**
* Set just the "day of week" field.
*
* @param int|string $day Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (1-5/2)
* @param int|string ...$days Single value (ie 1), multiple values (ie 1,3), range (ie 1-3), or step values (1-5/2)
*/
final public function daysOfWeek($day, ...$days): self
{
return $this->spliceIntoPosition(CronExpression::DOW, $day, ...$days);
}
/**
* Set just the "day of week" field.
*/
final public function weekdays(): self
{
return $this->daysOfWeek('1-5');
}
/**
* Set just the "day of week" field.
*/
final public function weekends(): self
{
return $this->daysOfWeek(0, 6);
}
/**
* Set just the "day of week" field.
*/
final public function mondays(): self
{
return $this->daysOfWeek(1);
}
/**
* Set just the "day of week" field.
*/
final public function tuesdays(): self
{
return $this->daysOfWeek(2);
}
/**
* Set just the "day of week" field.
*/
final public function wednesdays(): self
{
return $this->daysOfWeek(3);
}
/**
* Set just the "day of week" field.
*/
final public function thursdays(): self
{
return $this->daysOfWeek(4);
}
/**
* Set just the "day of week" field.
*/
final public function fridays(): self
{
return $this->daysOfWeek(5);
}
/**
* Set just the "day of week" field.
*/
final public function saturdays(): self
{
return $this->daysOfWeek(6);
}
/**
* Set just the "day of week" field.
*/
final public function sundays(): self
{
return $this->daysOfWeek(0);
}
/**
* Set just the "hour" and optionally the "minute" field(s).
*
* @param string $time Integer for just the hour (ie 2) or "HH:MM" for hour and minute (ie "14:30")
*/
final public function at(string $time): self
{
$segments = \explode(':', $time);
return $this
->hours($segments[0])
->minutes(2 === \count($segments) ? $segments[1] : 0)
;
}
/**
* @param int|string $value
* @param int|string ...$values
*/
private function spliceIntoPosition(int $position, $value, ...$values): self
{
$segments = \explode(' ', $this->expression);
if (5 !== \count($segments)) { // reset if set to alias or invalid
$this->expression = self::DEFAULT_EXPRESSION;
return $this->spliceIntoPosition($position, $value);
}
$segments[$position] = \implode(',', \array_merge([$value], $values));
return $this->cron(\implode(' ', $segments));
}
private function getTimezoneValue(): string
{
return ($this->getTimezone() ?? new \DateTimeZone(\date_default_timezone_get()))->getName();
}
}