Skip to content

Commit 9586d9c

Browse files
committed
Split restart method into setRestart and shouldRestart
1 parent 6e85cff commit 9586d9c

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/Symfony/Component/Scheduler/Generator/MessageGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ public function getMessages(): \Generator
3636
{
3737
$checkpoint = $this->checkpoint();
3838

39-
if ($this->schedule?->restart()) {
39+
if ($this->schedule?->shouldRestart()) {
4040
unset($this->triggerHeap);
4141
$this->waitUntil = new \DateTimeImmutable('@0');
42-
$this->schedule->restart(false);
42+
$this->schedule->setRestart(false);
4343
}
4444

4545
if (!$this->waitUntil

src/Symfony/Component/Scheduler/Schedule.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ final class Schedule implements ScheduleProviderInterface
2121
private array $messages = [];
2222
private ?LockInterface $lock = null;
2323
private ?CacheInterface $state = null;
24-
25-
private bool $restart = false;
24+
private bool $shouldRestart = false;
2625

2726
public static function with(RecurringMessage $message, RecurringMessage ...$messages): static
2827
{
@@ -34,7 +33,7 @@ public static function with(RecurringMessage $message, RecurringMessage ...$mess
3433
*/
3534
public function add(RecurringMessage $message, RecurringMessage ...$messages): static
3635
{
37-
$this->restart(true);
36+
$this->setRestart(true);
3837

3938
return static::doAdd($this, $message, ...$messages);
4039
}
@@ -58,15 +57,18 @@ private static function doAdd(self $schedule, RecurringMessage $message, Recurri
5857
public function remove(RecurringMessage $message): static
5958
{
6059
unset($this->messages[$message->getId()]);
61-
$this->restart(true);
60+
$this->setRestart(true);
6261

6362
return $this;
6463
}
6564

65+
/**
66+
* @return $this
67+
*/
6668
public function clear(): static
6769
{
6870
$this->messages = [];
69-
$this->restart(true);
71+
$this->setRestart(true);
7072

7173
return $this;
7274
}
@@ -117,8 +119,13 @@ public function getSchedule(): static
117119
return $this;
118120
}
119121

120-
public function restart(bool $restart = null): bool
122+
public function shouldRestart(): bool
123+
{
124+
return $this->shouldRestart;
125+
}
126+
127+
public function setRestart(bool $shouldRestart): bool
121128
{
122-
return $this->restart = $restart ?? $this->restart;
129+
return $this->shouldRestart = $shouldRestart;
123130
}
124131
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy