public function getInstance(InstanceFactory $factory, Binder $binder)
{
$instance = $binder->getInstance();
if ($instance) {
return $instance;
}
$className = $binder->getBoundClassName() ?: $binder->getClassName();
$scope = $binder->getScope();
if ($scope == Scope::SINGLETON) {
return $this->singletonInstance($factory, $className);
}
if ($scope == Scope::PROTOTYPE) {
return $factory->createInstance($this, $className);
}
throw new BadMethodCallException("Unknown scope: {$scope}");
}