texdc / Momento

A common set of domain event tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

A common set of domain event tools

License:MIT License


Languages

Language:PHP 100.0%