Skip to content

Commit 65a1385

Browse files
committed
refactor: extract method
1 parent 3924339 commit 65a1385

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

system/Config/Factories.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,8 @@ public static function __callStatic(string $component, array $arguments)
162162
return null;
163163
}
164164

165-
self::$instances[$options['component']][$class] = new $class(...$arguments);
166-
self::$aliases[$options['component']][$alias] = $class;
167-
self::$updated[$options['component']] = true;
165+
self::createInstance($options['component'], $class, $arguments);
166+
self::$aliases[$options['component']][$alias] = $class;
168167

169168
// If a short classname is specified, also register FQCN to share the instance.
170169
if (! isset(self::$aliases[$options['component']][$class])) {
@@ -192,8 +191,7 @@ private static function getDefinedInstance(array $options, string $alias, array
192191
return self::$instances[$options['component']][$class];
193192
}
194193

195-
self::$instances[$options['component']][$class] = new $class(...$arguments);
196-
self::$updated[$options['component']] = true;
194+
self::createInstance($options['component'], $class, $arguments);
197195

198196
return self::$instances[$options['component']][$class];
199197
}
@@ -218,6 +216,15 @@ private static function getDefinedInstance(array $options, string $alias, array
218216
return null;
219217
}
220218

219+
/**
220+
* Creates the shared instance.
221+
*/
222+
private static function createInstance(string $component, string $class, array $arguments): void
223+
{
224+
self::$instances[$component][$class] = new $class(...$arguments);
225+
self::$updated[$component] = true;
226+
}
227+
221228
/**
222229
* Is the component Config?
223230
*

0 commit comments

Comments
 (0)