public function detach(string $eventName, $handler): void
    {
        if (is_object($handler) == false && is_callable($handler) == false) {
            throw new InvalidArgumentException(
                sprintf('Event handler must be either an object or a callable %s given.', gettype($handler))
            );
        }

        if (isset($this->events[$eventName]) == false) {
            return;
        }

        $priorityQueue = $this->events[$eventName];
        $priorityQueue->setExtractFlags(SplPriorityQueue::EXTR_BOTH);
        $priorityQueue->top();

        $newPriorityQueue = $this->createQueue();

        while ($priorityQueue->valid()) {
            $data = $priorityQueue->current();
            $priorityQueue->next();

            if ($data['data'] !== $handler) {
                $newPriorityQueue->insert($data['data'], $data['priority']);
            }
        }

        $this->events[$eventName] = $newPriorityQueue;
    }