TODO

@param $item
@param $handler
325129
public function addResult($item, $handler)
    {
        $this->result[] = $item;
        $this->events[] = array($item, $handler);
        $this->count++;
    }
1198959
protected function handle($handler) {
	$handler_type = $this->get_handler_type($handler);
	
	// unmatched requests
	if (empty($handler) || empty($handler_type)) {
		$exception = bootstrap::get_library('exception');
		throw new $exception('no route found', response::STATUS_NOT_FOUND);
	}
	
	// default flow: matched requests
	$this->{'load_handler_as_'.$handler_type}($handler);
}
822471
public function process(Request $request, Handler $handler): Response
    {
        try {
            return $handler->handle($request);
        } catch (Throwable $e) {
            return $this->formatException($e);
        }
    }
1243143
public function attach($eventType, $handler, $priority = 100)
    {
        if (!isset($this->listeners[$eventType])) {
            if ($this->enablePriorities) {
                $priorityQueue = new PriorityQueue();
                $priorityQueue->setExtractFlags(PriorityQueue::EXTR_DATA);
            } else {
                $priorityQueue = [];
            }

            $this->listeners[$eventType] = $priorityQueue;
        }

        if (is_object($this->listeners[$eventType])) {
            /** @var PriorityQueue $priorityQueue */
            $priorityQueue = &$this->listeners[$eventType];
            $priorityQueue->insert($handler, $priority);
        } else {
            $this->listeners[$eventType][] = $handler;
        }
    }
631325
public function replace($handler, $bindTo = true)
    {
        if ($bindTo && $handler instanceof Closure) {
            $handler = $handler->bindTo($this, $this);
        }
        $this->handler = $handler;
    }
690818
public function once(string $event, callable $handler): void
    {
        $this->on($event, $handler, true);
    }
835518
public function addItem($item)
    {
        $indentation = $this->indent($this->indentation);

        $this->buffer[] = $indentation.$item;
    }
784689
public function withHandler($handler): self
    {
        return tap($this, function ($request) use ($handler) {
            return $this->handler = $handler;
        });
    }
527459
public function bind($cmd, $handler)
    {
        $cmds = array_map('trim', explode(' ', $cmd));

        foreach ($cmds as $cmd) {
            if ($cmd) {
                if (!isset($this->listeners[$cmd])) {
                    $this->listeners[$cmd] = array();
                }

                if ((is_array($handler) && count($handler) == 2 && is_object($handler[0]) && method_exists($handler[0], $handler[1]))
                || function_exists($handler)) {
                    $this->listeners[$cmd][] = $handler;
                }
            }
        }

        return $this;
    }
342477
public function var_dump($item)
    {
        if ($this->hasCollector('vardump')) {
            /** @var VarDumpCollector $collector */
            $collector = $this->getCollector('vardump');
            $collector->addVarDump($item);
        }
    }
485093
public function push(string $name, string $handler)
    {
        if (! isset($this->handlers[$name])) {
            $this->handlers[$name] = [];
        }

        if (! in_array($handler, $this->handlers[$name])) {
            $this->handlers[$name][] = $handler;
        }
    }
1038410
static function wrap($data, $handler=null) {
		$handler = $handler ?: 'dirtsimple\imposer\Promise::deferred_throw';
		return ( $data instanceof static  && $data->handler === $handler ) ? $data : new static($data, $handler);
	}
1115744
public function listen($handler)
	{
		if (!($this->dispatcher instanceof DispatcherInterface))
		{
			throw new \RuntimeException('Event dispatcher has not been set.');
		}

		$this->dispatcher->addListener($handler, 'onLog');
	}
1016116
private function skip($item, $key): void
    {
        $this->shouldSkip = false;
        $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::SKIP, $item, $key, $this));
    }
936522
public function queryAndFetch($sql, Closure $handler)
	{
		$sth = $this->query($sql);

		while (($row = $sth->fetch(PDO::FETCH_ASSOC)))
			$handler($row);
	}
19902
static function set_current_user_getter( $handler ){
		if( ! is_callable($handler) ){
			trigger_error( 'current user getter is not callable ('.var_export($handler,1).')', E_USER_WARNING );
			return false;
		}
		self::$current_user_func = $handler;
		return true;	
	}
661324
protected function addHandler($event, callable $handler)
    {
        if (!isset($this->handlers[$event])) {
            throw new Exception("No such event '$event'");
        }

        if (!is_callable($handler)) {
            throw new Exception("Event handlers must be callable");
        }

        $this->handlers[$event][] = $handler;

        //Return last key
        return count($this->handlers[$event]) - 1;
    }