Skip to content

Instantly share code, notes, and snippets.

@SamMousa
Created January 11, 2018 14:19
Show Gist options
  • Save SamMousa/cf9abb75c0b8554b43db9efc20faa3e3 to your computer and use it in GitHub Desktop.
Save SamMousa/cf9abb75c0b8554b43db9efc20faa3e3 to your computer and use it in GitHub Desktop.
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