Created
May 31, 2017 00:24
-
-
Save emir/b52a382d932989ae6831932baf9914c3 to your computer and use it in GitHub Desktop.
Without Visual Debts (Not my opinion)
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 | |
| class Event { | |
| protected $events = []; | |
| function listen($name, $handler) | |
| { | |
| $this->events[$name][] = $handler; | |
| } | |
| function fire($name) | |
| { | |
| if (! array_key_exists($name, $this->events)) { | |
| return false; | |
| } | |
| foreach ($this->events[$name] as $event) { | |
| $event(); | |
| } | |
| return true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment