本文整理匯總了PHP中Symfony\Component\Console\Input\InputDefinition::getArgument方法的典型用法代碼示例。如果您正苦於以下問題:PHP InputDefinition::getArgument方法的具體用法?PHP InputDefinition::getArgument怎麽用?PHP InputDefinition::getArgument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Input\InputDefinition
的用法示例。
在下文中一共展示了InputDefinition::getArgument方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getArgument
/**
* Returns the argument value for a given argument name.
*
* @param string $name The argument name
*
* @return mixed The argument value
*
* @throws InvalidArgumentException When argument given doesn't exist
*/
public function getArgument($name)
{
if (!$this->definition->hasArgument($name)) {
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
}
return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault();
}
示例2: setArgumentDescription
private function setArgumentDescription(InputDefinition $definition, $name, $description)
{
$argument = $definition->getArgument($name);
if ($argument instanceof InputArgument) {
$argument->setDescription($description);
}
}
示例3: testGetInvalidArgument
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "bar" argument does not exist.
*/
public function testGetInvalidArgument()
{
$this->initializeArguments();
$definition = new InputDefinition();
$definition->addArguments(array($this->foo));
$definition->getArgument('bar');
}
示例4: testGetArgument
public function testGetArgument()
{
$this->initializeArguments();
$definition = new InputDefinition();
$definition->addArguments(array($this->foo));
$this->assertEquals($this->foo, $definition->getArgument('foo'), '->getArgument() returns a InputArgument by its name');
try {
$definition->getArgument('bar');
$this->fail('->getArgument() throws an exception if the InputArgument name does not exist');
} catch (\Exception $e) {
$this->assertInstanceOf('\\Exception', $e, '->getArgument() throws an exception if the InputArgument name does not exist');
$this->assertEquals('The "bar" argument does not exist.', $e->getMessage());
}
}