/** * @param WorkerInterface $worker * * @throws \LogicException if a worker with the name exists */ public function addWorker(WorkerInterface $worker) { $name = $worker->getName(); if (isset($this->workers[$name])) { throw new \LogicException(sprintf('A worker named `%s` already exists', $name)); } $this->workers[$name] = $worker; }