Simple domain event library inspired by Vaughn Vernon's book Implementing Domain Driven Design, and some of his code samples.
namespace My\Event;
use texdc\momento\AbstractEventHandler;
use texdc\momento\EventInterface;
final class Handler extends AbstractEventHandler
{
protected static $validEventTypes = [
FooEvent::TYPE,
BarEvent::TYPE,
];
public function __invoke(EventInterface $anEvent)
{
$type = $anEvent->eventType();
$this->guardValidEventType($type);
call_user_func([$this, $type], $anEvent);
}
// ...
}