Skip to content

Commit

Permalink
Allow method chaining for watch
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk authored Mar 28, 2024
1 parent 252d478 commit bf63f20
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Traits/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ public function isWatched(string $event): bool
/**
* @throws InvalidStateException
*/
protected function watch(string $event, bool $clear = false): void
protected function watch(string $event, bool $clear = false): static
{
if (!$clear && $this->isWatched($event)) {
throw new InvalidStateException('Event "'.$event.'" is already watched. Use $clear to re-register.');
}

$this->events[$event] = [];
return $this;
}


Expand Down

0 comments on commit bf63f20

Please sign in to comment.