public function get($name)
{
if (!is_string($name)) {
throw new InvalidArgumentException(sprintf('The name parameter must be of type string, %s given', is_object($name) ? get_class($name) : gettype($name)));
}
// Try to find the entry in the singleton map
if (array_key_exists($name, $this->singletonEntries)) {
return $this->singletonEntries[$name];
}
$definition = $this->definitionSource->getDefinition($name);
if (!$definition) {
throw new NotFoundException("No entry or class found for '{$name}'");
}
$value = $this->resolveDefinition($definition);
// If the entry is singleton, we store it to always return it without recomputing it
if ($definition->getScope() === Scope::SINGLETON) {
$this->singletonEntries[$name] = $value;
}
return $value;
}