Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Simplify condition structure and add @throw to docblock for resolve method #50863

Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Illuminate/Support/MultipleInstanceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Closure;
use InvalidArgumentException;
use RuntimeException;
saMahmoudzadeh marked this conversation as resolved.
Show resolved Hide resolved

abstract class MultipleInstanceManager
{
Expand Down Expand Up @@ -64,7 +63,7 @@ abstract public function setDefaultInstance($name);
abstract public function getInstanceConfig($name);

/**
* Get an instance instance by name.
* Get an instance by name.
*
* @param string|null $name
* @return mixed
Expand Down Expand Up @@ -94,6 +93,7 @@ protected function get($name)
* @return mixed
*
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
protected function resolve($name)
{
Expand All @@ -104,20 +104,20 @@ protected function resolve($name)
}

if (! array_key_exists('driver', $config)) {
throw new RuntimeException("Instance [{$name}] does not specify a driver.");
throw new \RuntimeException("Instance [{$name}] does not specify a driver.");
saMahmoudzadeh marked this conversation as resolved.
Show resolved Hide resolved
}

if (isset($this->customCreators[$config['driver']])) {
return $this->callCustomCreator($config);
} else {
$driverMethod = 'create'.ucfirst($config['driver']).'Driver';
}

if (method_exists($this, $driverMethod)) {
return $this->{$driverMethod}($config);
} else {
throw new InvalidArgumentException("Instance driver [{$config['driver']}] is not supported.");
}
$driverMethod = 'create'.ucfirst($config['driver']).'Driver';

if (method_exists($this, $driverMethod)) {
return $this->{$driverMethod}($config);
}

throw new InvalidArgumentException("Instance driver [{$config['driver']}] is not supported.");
}

/**
Expand Down
Loading