Returns whether an option is defined in the format.
public isOptionDefined ( string $name ) : boolean | ||
$name | string | The long or short option name. |
Résultat | boolean | Returns `true` if the option exists and `false` otherwise. |
/** * {@inheritdoc} */ public function hasOption($name) { return $this->args ? $this->args->isOptionDefined($name) : false; }
public function testIsOptionDefined() { $format = ArgsFormat::build()->addOption(new Option('option1', null, Option::NO_VALUE))->addOption(new Option('option2', null, Option::OPTIONAL_VALUE))->getFormat(); $args = new Args($format); $this->assertTrue($args->isOptionDefined('option1')); $this->assertTrue($args->isOptionDefined('option2')); $this->assertFalse($args->isOptionSet('foo')); }