GetOptionKit\OptionCollection::get PHP Method

get() public method

* Get spec by spec id
public get ( $id )
    public function get($id)
    {
        if (isset($this->data[$id])) {
            return $this->data[$id];
        } else {
            if (isset($this->longOptions[$id])) {
                return $this->longOptions[$id];
            } else {
                if (isset($this->shortOptions[$id])) {
                    return $this->shortOptions[$id];
                }
            }
        }
    }

Usage Example

示例#1
0
 public function testIntegerTypeNumericWithEqualSign()
 {
     $opt = new OptionCollection();
     $opt->add('b|bar:=number', 'option with integer type');
     $spec = $opt->get('bar');
     $this->assertTrue($spec->isTypeNumber());
     $parser = new OptionParser($opt);
     $result = $parser->parse(explode(' ', 'app -b=123123'));
     $this->assertNotNull($result);
     $this->assertNotNull($result->bar);
     $this->assertEquals(123123, $result->bar);
 }