You are here

public function DefinitionDecorator::getArgument in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/DefinitionDecorator.php \Symfony\Component\DependencyInjection\DefinitionDecorator::getArgument()

Gets an argument to pass to the service constructor/factory method.

If replaceArgument() has been used to replace an argument, this method will return the replacement value.

Parameters

int $index:

Return value

mixed The argument value

Throws

OutOfBoundsException When the argument does not exist

Overrides Definition::getArgument

File

vendor/symfony/dependency-injection/DefinitionDecorator.php, line 172

Class

DefinitionDecorator
This definition decorates another definition.

Namespace

Symfony\Component\DependencyInjection

Code

public function getArgument($index) {
  if (array_key_exists('index_' . $index, $this->arguments)) {
    return $this->arguments['index_' . $index];
  }
  $lastIndex = count(array_filter(array_keys($this->arguments), 'is_int')) - 1;
  if ($index < 0 || $index > $lastIndex) {
    throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, $lastIndex));
  }
  return $this->arguments[$index];
}