From 489ed7c9ed6e55a154095fa2f7cfe9ef51fa253e Mon Sep 17 00:00:00 2001 From: "S.a Mahmoudzadeh" Date: Sun, 31 Mar 2024 11:47:33 +0330 Subject: [PATCH 1/3] refactor(multipleInstanceManager.php): reduce indent and add @throw to doc block for resolve method --- .../Support/MultipleInstanceManager.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Illuminate/Support/MultipleInstanceManager.php b/src/Illuminate/Support/MultipleInstanceManager.php index 8544bdf71b34..a0e07738b195 100644 --- a/src/Illuminate/Support/MultipleInstanceManager.php +++ b/src/Illuminate/Support/MultipleInstanceManager.php @@ -94,6 +94,7 @@ protected function get($name) * @return mixed * * @throws \InvalidArgumentException + * @throws \RuntimeException */ protected function resolve($name) { @@ -104,20 +105,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."); } 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."); } /** From 421f878082c060597b61d92dedcbf7fed47deac5 Mon Sep 17 00:00:00 2001 From: "S.a Mahmoudzadeh" Date: Sun, 31 Mar 2024 12:21:26 +0330 Subject: [PATCH 2/3] fix styleCi issue, update description of instance method --- src/Illuminate/Support/MultipleInstanceManager.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Illuminate/Support/MultipleInstanceManager.php b/src/Illuminate/Support/MultipleInstanceManager.php index a0e07738b195..b61070e0fdc3 100644 --- a/src/Illuminate/Support/MultipleInstanceManager.php +++ b/src/Illuminate/Support/MultipleInstanceManager.php @@ -4,7 +4,6 @@ use Closure; use InvalidArgumentException; -use RuntimeException; abstract class MultipleInstanceManager { @@ -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 From 327683ba0948d179f796f6e72bdcb87dd10aaf4e Mon Sep 17 00:00:00 2001 From: "s.h.mahmoudzadeh" Date: Sun, 31 Mar 2024 16:16:52 +0330 Subject: [PATCH 3/3] fix: resolve review code --- src/Illuminate/Support/MultipleInstanceManager.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Support/MultipleInstanceManager.php b/src/Illuminate/Support/MultipleInstanceManager.php index b61070e0fdc3..575e37d2dadd 100644 --- a/src/Illuminate/Support/MultipleInstanceManager.php +++ b/src/Illuminate/Support/MultipleInstanceManager.php @@ -4,6 +4,7 @@ use Closure; use InvalidArgumentException; +use RuntimeException; abstract class MultipleInstanceManager { @@ -104,7 +105,7 @@ 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."); } if (isset($this->customCreators[$config['driver']])) {