texdc/momento

A library for domain events

v2.0.0 2017-10-14 20:44 UTC

This package is not auto-updated.

Last update: 2024-12-21 16:20:40 UTC


README

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