Skip to content

texdc/Momento

Repository files navigation

Momento

Simple domain event library inspired by Vaughn Vernon's book Implementing Domain Driven Design, and some of his code samples.

Latest Build Dependencies Latest Stable Version Total Downloads License

Event Handlers

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);
    }
    
    // ...
}