/** * Registers a command. * * @param CommandInterface $command * * @return void */ public function register(CommandInterface $command) { /* * Gets the name of the command * @var string */ $name = $command->getCommand(); /* * Check if the command isn't already registered * otherwise throw an exception */ if (array_key_exists($name, $this->commands)) { throw new CommandException("Command with name '{$name}' already registered"); } /* * Adds the command to the array */ $this->commands[$name] = $command; }