isArgumentDefined() public method

Returns whether an argument is defined in the format.
public isArgumentDefined ( string | integer $name ) : boolean
$name string | integer The argument name or its 0-based position in the argument list.
return boolean Returns `true` if the argument exists and `false` otherwise.
コード例 #1
0
ファイル: ArgsInput.php プロジェクト: webmozart/console
 /**
  * {@inheritdoc}
  */
 public function hasArgument($name)
 {
     return $this->args ? $this->args->isArgumentDefined($name) : false;
 }
コード例 #2
0
ファイル: ArgsTest.php プロジェクト: webmozart/console
 public function testIsArgumentDefined()
 {
     $format = ArgsFormat::build()->addArgument(new Argument('argument1'))->addArgument(new Argument('argument2'))->getFormat();
     $args = new Args($format);
     $this->assertTrue($args->isArgumentDefined('argument1'));
     $this->assertTrue($args->isArgumentDefined('argument2'));
     $this->assertFalse($args->isArgumentDefined('foo'));
 }