@@ -40,8 +40,9 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function add(TaskInterface $task): bool |
| 42 | 42 | { |
| 43 | - if ($this->exists($task)) |
|
| 44 | - return false; |
|
| 43 | + if ($this->exists($task)) { |
|
| 44 | + return false; |
|
| 45 | + } |
|
| 45 | 46 | |
| 46 | 47 | $this->tasks[] = $task; |
| 47 | 48 | |
@@ -55,8 +56,9 @@ discard block |
||
| 55 | 56 | */ |
| 56 | 57 | public function remove(TaskInterface $task): bool |
| 57 | 58 | { |
| 58 | - if (!$this->exists($task)) |
|
| 59 | - return false; |
|
| 59 | + if (!$this->exists($task)) { |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 60 | 62 | |
| 61 | 63 | unset($this->tasks[array_search($task, $this->tasks)]); |
| 62 | 64 | |
@@ -77,16 +79,18 @@ discard block |
||
| 77 | 79 | { |
| 78 | 80 | foreach ($this->tasks as $task) |
| 79 | 81 | { |
| 80 | - if (time() < $task->getExpiryTime()) |
|
| 81 | - continue; |
|
| 82 | + if (time() < $task->getExpiryTime()) { |
|
| 83 | + continue; |
|
| 84 | + } |
|
| 82 | 85 | |
| 83 | 86 | $result = $task->run(); |
| 84 | 87 | |
| 85 | 88 | // It is removed first. |
| 86 | 89 | $this->remove($task); |
| 87 | 90 | |
| 88 | - if ($result instanceof TaskInterface) |
|
| 89 | - $this->add($result); |
|
| 91 | + if ($result instanceof TaskInterface) { |
|
| 92 | + $this->add($result); |
|
| 93 | + } |
|
| 90 | 94 | } |
| 91 | 95 | } |
| 92 | 96 | } |
| 93 | 97 | \ No newline at end of file |
@@ -45,12 +45,12 @@ |
||
| 45 | 45 | */ |
| 46 | 46 | public function run(): ?TaskInterface |
| 47 | 47 | { |
| 48 | - if (time() >= $this->childTask->getExpiryTime()) |
|
| 49 | - { |
|
| 48 | + if (time() >= $this->childTask->getExpiryTime()) { |
|
| 50 | 49 | $result = $this->childTask->run(); |
| 51 | 50 | |
| 52 | - if ($result instanceof TaskInterface) |
|
| 53 | - $this->childTask = $result; |
|
| 51 | + if ($result instanceof TaskInterface) { |
|
| 52 | + $this->childTask = $result; |
|
| 53 | + } |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $this->expiryTime = $this->getExpiryTime() + $this->getRepeatInterval(); |
@@ -44,15 +44,18 @@ |
||
| 44 | 44 | { |
| 45 | 45 | $result = call_user_func_array($this->getCallback(), $this->getStoredArguments()); |
| 46 | 46 | |
| 47 | - if (!($result instanceof TaskInterface)) |
|
| 48 | - return null; |
|
| 47 | + if (!($result instanceof TaskInterface)) { |
|
| 48 | + return null; |
|
| 49 | + } |
|
| 49 | 50 | |
| 50 | 51 | return $result; |
| 51 | 52 | } |
| 52 | 53 | |
| 53 | 54 | public function cancel(): void |
| 54 | 55 | { |
| 55 | - $this->callback = function () {}; |
|
| 56 | + $this->callback = function () |
|
| 57 | + { |
|
| 58 | +}; |
|
| 56 | 59 | $this->setExpiryTime(0); |
| 57 | 60 | } |
| 58 | 61 | |