Created
November 27, 2018 12:38
-
-
Save frankdejonge/e64da3a093b6380910891214f1a6c770 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
final class EventDispatcher { | |
private $listeners = []; | |
public function listen(callable $listener) | |
{ | |
$this->listeners[] = $listener; | |
} | |
public function dispatch(object $event) | |
{ | |
foreach ($this->listeners as $listener) $listener($event); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment