/** * @param Chain $chain * @return string * @throws \Exception */ public function createChain(Chain $chain) { $this->chains[$chain->getName()] = $chain; $rulesCounter = count($chain->getRulesList()); $command = new Command($this->name); if (1 < $rulesCounter) { throw new \Exception('Maximum number Rules on creation is 1.'); } else { if (1 === $rulesCounter) { $command->setOptions((string) current($chain->getRulesList())); } } return $command->createChain($chain->getName()); }