public function addFactory(ProcessorFactoryInterface $factory, $priority = 0)
    {
        $this->factories[$priority][] = $factory;
        // sort by priority and flatten
        // we do it here due to performance reasons (it is expected that it will be only several factories,
        // but the getProcessor method will be called a lot of times)
        \krsort($this->factories);
        $this->sortedFactories = \array_merge(...$this->factories);
    }