This repository has been archived by the owner on May 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb825df
commit bd1ef40
Showing
6 changed files
with
40 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
\spl_autoload_register(function ($class) { | ||
// Project-specific namespace prefix | ||
$prefix = 'ParagonIE\\Pharaoh'; | ||
|
||
// Base directory for the namespace prefix | ||
$base_dir = __DIR__.'/Pharaoh/'; | ||
|
||
// Does the class use the namespace prefix? | ||
$len = \strlen($prefix); | ||
if (\strncmp($prefix, $class, $len) !== 0) { | ||
// no, move to the next registered autoloader | ||
return; | ||
} | ||
|
||
// Get the relative class name | ||
$relative_class = \substr($class, $len); | ||
|
||
// Replace the namespace prefix with the base directory, replace namespace | ||
// separators with directory separators in the relative class name, append | ||
// with .php | ||
$file = $base_dir. | ||
\str_replace( | ||
['\\', '_'], | ||
'/', | ||
$relative_class | ||
).'.php'; | ||
|
||
// If the file exists, require it | ||
if (\file_exists($file)) { | ||
require $file; | ||
} | ||
}); |