private function createBuilderForElements(array $elements, ArgsFormat $baseFormat = null)
    {
        $builder = new ArgsFormatBuilder($baseFormat);

        foreach ($elements as $element) {
            if ($element instanceof CommandName) {
                $builder->addCommandName($element);
            } elseif ($element instanceof CommandOption) {
                $builder->addCommandOption($element);
            } elseif ($element instanceof Option) {
                $builder->addOption($element);
            } elseif ($element instanceof Argument) {
                $builder->addArgument($element);
            } else {
                throw new InvalidArgumentException(sprintf(
                    'Expected instances of CommandName, CommandOption, '.
                    'Option or Argument. Got: %s',
                    is_object($element) ? get_class($element) : gettype($element)
                ));
            }
        }

        return $builder;
    }
private function createBuilderForElements(array $elements, ArgsFormat $baseFormat = null)
    {
        $builder = new ArgsFormatBuilder($baseFormat);

        foreach ($elements as $element) {
            if ($element instanceof CommandName) {
                $builder->addCommandName($element);
            } elseif ($element instanceof CommandOption) {
                $builder->addCommandOption($element);
            } elseif ($element instanceof Option) {
                $builder->addOption($element);
            } elseif ($element instanceof Argument) {
                $builder->addArgument($element);
            } else {
                throw new InvalidArgumentException(sprintf(
                    'Expected instances of CommandName, CommandOption, '.
                    'Option or Argument. Got: %s',
                    is_object($element) ? get_class($element) : gettype($element)
                ));
            }
        }

        return $builder;
    }
private function createBuilderForElements ( array $ elements , ArgsFormat $ baseFormat = null ) { $ builder = new ArgsFormatBuilder ( $ baseFormat ) ; foreach ( $ elements as $ element ) { if ( $ element instanceof CommandName ) { $ builder -> addCommandName ( $ element ) ; } elseif ( $ element instanceof CommandOption ) { $ builder -> addCommandOption ( $ element ) ; } elseif ( $ element instanceof Option ) { $ builder -> addOption ( $ element ) ; } elseif ( $ element instanceof Argument ) { $ builder -> addArgument ( $ element ) ; } else { throw new InvalidArgumentException ( sprintf ( 'Expected instances of CommandName, CommandOption, ' . 'Option or Argument. Got: %s' , is_object ( $ element ) ? get_class ( $ element ) : gettype ( $ element ) ) ) ; } } return $ builder ; }
Creates a format builder for a set of arguments and options.

@param array      $elements   The arguments and options to add to the
builder.
@param ArgsFormat $baseFormat The base format.

@return ArgsFormatBuilder The created builder.
Creates a format builder for a set of arguments and options .