Webmozart\Console\Api\Args\Format\ArgsFormatBuilder::hasOption PHP Method

hasOption() public method

You can either pass the long or the short name of the option.
public hasOption ( string $name, boolean $includeBase = true ) : boolean
$name string The long or short option name.
$includeBase boolean Whether to include options in the base format in the search.
return boolean Returns `true` if the option with the given name could be found and `false` otherwise.
    public function hasOption($name, $includeBase = true)
    {
        Assert::string($name, 'The option name must be a string or an integer. Got: %s');
        Assert::notEmpty($name, 'The option name must not be empty.');
        Assert::boolean($includeBase, 'The parameter $includeBase must be a boolean. Got: %s');
        if (isset($this->options[$name]) || isset($this->optionsByShortName[$name])) {
            return true;
        }
        if ($includeBase && $this->baseFormat) {
            return $this->baseFormat->hasOption($name);
        }
        return false;
    }

Usage Example

 /**
  * @expectedException \InvalidArgumentException
  */
 public function testHasOptionFailsIfIncludeBaseNoBoolean()
 {
     $this->builder->hasOption('option', 1234);
 }