public function setBranch($branch)
    {
        if (!is_string($branch)) {
            throw new InvalidArgumentException('string', 0);
        }

        $oldBranch = $this->branch;
        $oldArg = $this->command->searchArgument($oldBranch);
        if (!$oldArg) {
            throw new Exception("Couldn't change the command to new branch. Was the Command object modified?");
        }
        $newArg = new Argument($branch);
        $this->command->replaceArgument($oldArg, $newArg);

        $this->branch = $branch;
        return $this;
    }