GetOptionKit\OptionCollection::add PHP Method

add() public method

add( [option object] )
public add ( )
    public function add()
    {
        $num = func_num_args();
        $args = func_get_args();
        $first = $args[0];
        if ($first instanceof Option) {
            $this->addOption($first);
        } else {
            if (is_string($first)) {
                $specString = $args[0];
                $desc = isset($args[1]) ? $args[1] : null;
                $key = isset($args[2]) ? $args[2] : null;
                // parse spec string
                $spec = new Option($specString);
                if ($desc) {
                    $spec->desc($desc);
                }
                if ($key) {
                    $spec->key = $key;
                }
                $this->addOption($spec);
                return $spec;
            } else {
                throw new LogicException('Unknown Spec Type');
            }
        }
    }

Usage Example

Ejemplo n.º 1
0
 public static function getSubCommandsSpecs()
 {
     $generateSpecs = new OptionCollection();
     $generateSpecs->add('i|input:', 'Input file')->isa('File');
     $generateSpecs->add('o|output?', 'Output directory')->isa('String')->defaultValue(null);
     $subCommandSpecs = (object) ['generate' => $generateSpecs];
     return $subCommandSpecs;
 }
All Usage Examples Of GetOptionKit\OptionCollection::add