Skip to content

Commit eff58b7

Browse files
committed
refactor: small improvement in loadInNamespace Autoloader
1 parent 7ef927b commit eff58b7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

system/Autoloader/Autoloader.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,14 @@ protected function loadInNamespace(string $class)
280280
}
281281

282282
foreach ($this->prefixes as $namespace => $directories) {
283+
$classNamespaceFind = strpos($class, $namespace);
284+
$classSubStr = substr($class, strlen($namespace));
285+
283286
foreach ($directories as $directory) {
284287
$directory = rtrim($directory, '\\/');
285288

286-
if (strpos($class, $namespace) === 0) {
287-
$filePath = $directory . str_replace('\\', DIRECTORY_SEPARATOR, substr($class, strlen($namespace))) . '.php';
289+
if ($classNamespaceFind === 0) {
290+
$filePath = $directory . str_replace('\\', DIRECTORY_SEPARATOR, $classSubStr) . '.php';
288291
$filename = $this->includeFile($filePath);
289292

290293
if ($filename) {

0 commit comments

Comments
 (0)