hasCommandOption() public method

You can either pass the long or the short name of the command option.
public hasCommandOption ( 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 command option with the given name could be found and `false` otherwise.
Exemplo n.º 1
0
 /**
  * Returns whether the builder contains a specific command option.
  *
  * You can either pass the long or the short name of the command option.
  *
  * @param string $name        The long or short option name.
  * @param bool   $includeBase Whether to include command options in the base
  *                            format in the search.
  *
  * @return bool Returns `true` if the command option with the given name
  *              could be found and `false` otherwise.
  */
 public function hasCommandOption($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->commandOptions[$name]) || isset($this->commandOptionsByShortName[$name])) {
         return true;
     }
     if ($includeBase && $this->baseFormat) {
         return $this->baseFormat->hasCommandOption($name);
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testHasCommandOptionFailsIfIncludeBaseNoBoolean()
 {
     $format = new ArgsFormat();
     $format->hasCommandOption('option', 1234);
 }