Skip to content

Commit 8786568

Browse files
committed
refactor: extract isNamespaced()
1 parent 1bf5130 commit 8786568

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

system/Config/Factories.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ class_exists($alias, false)
242242
// Have to do this the hard way...
243243
$locator = Services::locator();
244244

245-
// Check if the class was namespaced
246-
if (strpos($alias, '\\') !== false) {
245+
// Check if the class alias was namespaced
246+
if (self::isNamespaced($alias)) {
247247
if (! $file = $locator->locateFile($alias, $options['path'])) {
248248
return null;
249249
}
@@ -267,6 +267,16 @@ class_exists($alias, false)
267267
return null;
268268
}
269269

270+
/**
271+
* Is the class alias namespaced or not?
272+
*
273+
* @param string $alias Class alias. See the $aliases property.
274+
*/
275+
private static function isNamespaced(string $alias): bool
276+
{
277+
return strpos($alias, '\\') !== false;
278+
}
279+
270280
/**
271281
* Verifies that a class & config satisfy the "preferApp" option
272282
*
@@ -414,7 +424,7 @@ public static function injectMock(string $component, string $alias, object $inst
414424
}
415425

416426
/**
417-
* Gets a basename from a class name, namespaced or not.
427+
* Gets a basename from a class alias, namespaced or not.
418428
*
419429
* @internal For testing only
420430
*/

0 commit comments

Comments
 (0)