Skip to content

Commit

Permalink
improved: genug\autoloader()
Browse files Browse the repository at this point in the history
  • Loading branch information
d4s6 committed Feb 21, 2018
1 parent 3584a37 commit 510222a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions genug_core/genug/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@

function autoloader($class)
{
if (\strpos($class, __NAMESPACE__) !== 0) {
if (\strpos($class, __NAMESPACE__ . '\\') !== 0) {
return;
}

$fileName = namespace\CORE_DIR . \DIRECTORY_SEPARATOR . \strtolower($class) . '.php';

$fileName = (function () use ($class) {
$relativePath = \str_replace('\\', \DIRECTORY_SEPARATOR, \strtolower($class));
return namespace\CORE_DIR . \DIRECTORY_SEPARATOR . $relativePath . '.php';
})();

$isProperFileName = (function () use ($fileName) {
$fileInfo = new \SplFileInfo($fileName);
return ($fileInfo->isFile() && $fileInfo->isReadable());
Expand Down

0 comments on commit 510222a

Please sign in to comment.