| Conditions | 3 |
| Paths | 3 |
| Total Lines | 25 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | public static function doAutoload($class) |
||
| 26 | { |
||
| 27 | // base directory for the namespace prefix |
||
| 28 | $base_dir = __DIR__ . '/../'; |
||
| 29 | |||
| 30 | // does the class use the namespace prefix? |
||
| 31 | $len = strlen(__NAMESPACE__); |
||
| 32 | if (strncmp(__NAMESPACE__, $class, $len) !== 0) { |
||
| 33 | // no, move to the next registered autoloader |
||
| 34 | return; |
||
| 35 | } |
||
| 36 | |||
| 37 | // get the relative class name |
||
| 38 | $relative_class = substr($class, $len); |
||
| 39 | |||
| 40 | // replace the namespace prefix with the base directory, replace namespace |
||
| 41 | // separators with directory separators in the relative class name, append |
||
| 42 | // with .php |
||
| 43 | $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
||
| 44 | |||
| 45 | // if the file exists, require it |
||
| 46 | if (file_exists($file)) { |
||
| 47 | require $file; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | } |
||
| 51 |