Created
January 11, 2018 14:19
-
-
Save SamMousa/cf9abb75c0b8554b43db9efc20faa3e3 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
class EventHandler.php { | |
private $handlerClass; | |
public function __construct(string $handlerClass) { | |
$this->handlerClass = $handlerClass | |
} | |
public function __invoke(... $args) { | |
$instance = new {$this->handlerClass}; | |
$instance->handle(... $args); | |
} | |
} | |
// Usage | |
... [ | |
'on afterLogin' => new EventHandler(AfterLoginHandler::class) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment