PHP code example of texdc / momento

1. Go to this page and download the library: Download texdc/momento library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

texdc / momento example snippets


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