@@ -21,8 +21,7 @@ final class Schedule implements ScheduleProviderInterface
21
21
private array $ messages = [];
22
22
private ?LockInterface $ lock = null ;
23
23
private ?CacheInterface $ state = null ;
24
-
25
- private bool $ restart = false ;
24
+ private bool $ shouldRestart = false ;
26
25
27
26
public static function with (RecurringMessage $ message , RecurringMessage ...$ messages ): static
28
27
{
@@ -34,7 +33,7 @@ public static function with(RecurringMessage $message, RecurringMessage ...$mess
34
33
*/
35
34
public function add (RecurringMessage $ message , RecurringMessage ...$ messages ): static
36
35
{
37
- $ this ->restart (true );
36
+ $ this ->setRestart (true );
38
37
39
38
return static ::doAdd ($ this , $ message , ...$ messages );
40
39
}
@@ -58,15 +57,18 @@ private static function doAdd(self $schedule, RecurringMessage $message, Recurri
58
57
public function remove (RecurringMessage $ message ): static
59
58
{
60
59
unset($ this ->messages [$ message ->getId ()]);
61
- $ this ->restart (true );
60
+ $ this ->setRestart (true );
62
61
63
62
return $ this ;
64
63
}
65
64
65
+ /**
66
+ * @return $this
67
+ */
66
68
public function clear (): static
67
69
{
68
70
$ this ->messages = [];
69
- $ this ->restart (true );
71
+ $ this ->setRestart (true );
70
72
71
73
return $ this ;
72
74
}
@@ -117,8 +119,13 @@ public function getSchedule(): static
117
119
return $ this ;
118
120
}
119
121
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
121
128
{
122
- return $ this ->restart = $ restart ?? $ this -> restart ;
129
+ return $ this ->shouldRestart = $ shouldRestart ;
123
130
}
124
131
}
0 commit comments