src/SecucardConnect/Event/EventDispatcher.php
public function dispatch($eventStr)
    {
        try {
            // decode as array because data proprty, which has unknown structure (only known by handler),
            // must remain array after mapping to event
            $arr = MapperUtil::jsonDecode($eventStr, true);
            $event = MapperUtil::map($arr, Event::class);
        } catch (Exception $e) {
            throw  new ClientError("Invalid event JSON", $e);
        }

        foreach ($this->handlerMap as $callback) {
            try {
                if ($callback->handle($event)) {
                    return;
                }
            } catch (Exception $e) {
                if (!$e instanceof AbstractError) {
                    throw  new ClientError("Unknown error processing the event", $e);
                } else {
                    throw $e;
                }
            }
        }
    }
public function dispatch($eventStr)
    {
        try {
            // decode as array because data proprty, which has unknown structure (only known by handler),
            // must remain array after mapping to event
            $arr = MapperUtil::jsonDecode($eventStr, true);
            $event = MapperUtil::map($arr, Event::class);
        } catch (Exception $e) {
            throw  new ClientError("Invalid event JSON", $e);
        }

        foreach ($this->handlerMap as $callback) {
            try {
                if ($callback->handle($event)) {
                    return;
                }
            } catch (Exception $e) {
                if (!$e instanceof AbstractError) {
                    throw  new ClientError("Unknown error processing the event", $e);
                } else {
                    throw $e;
                }
            }
        }
    }
public function dispatch ( $ eventStr ) { try { // decode as array because data proprty, which has unknown structure (only known by handler), // must remain array after mapping to event $ arr = MapperUtil :: jsonDecode ( $ eventStr , true ) ; $ event = MapperUtil :: map ( $ arr , Event :: class ) ; } catch ( Exception $ e ) { throw new ClientError ( "Invalid event JSON" , $ e ) ; } foreach ( $ this -> handlerMap as $ callback ) { try { if ( $ callback -> handle ( $ event ) ) { return ; } } catch ( Exception $ e ) { if ( ! $ e instanceof AbstractError ) { throw new ClientError ( "Unknown error processing the event" , $ e ) ; } else { throw $ e ; } } } }
Dispatch the event string to a responsible handler if any.
@param string $eventStr The event JSON.
@return void
@throws AbstractError
Dispatch the event string to a responsible handler if any .