Place hasArgument() check at the beginning of getArgument() method

If input definition doesn't have specified argument, then unnecessary operations will be executed ($arguments = is_int($name) ? array_values($this->arguments) : $this->arguments;)
This commit is contained in:
alexpods 2013-04-27 06:13:33 +04:00
parent 06d5fb171f
commit 992c218913
1 changed files with 2 additions and 2 deletions

View File

@ -153,12 +153,12 @@ class InputDefinition
*/
public function getArgument($name)
{
$arguments = is_int($name) ? array_values($this->arguments) : $this->arguments;
if (!$this->hasArgument($name)) {
throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
}
$arguments = is_int($name) ? array_values($this->arguments) : $this->arguments;
return $arguments[$name];
}