Conditions | 5 |
Paths | 8 |
Total Lines | 35 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 1 |
1 | <?php |
||
20 | function autoload_NML($class) |
||
|
|||
21 | { |
||
22 | static $DS = DIRECTORY_SEPARATOR; |
||
23 | |||
24 | if ($class[0] == '\\') { |
||
25 | $class = substr($class, 1); |
||
26 | } |
||
27 | |||
28 | $classArray = explode('\\', $class); |
||
29 | |||
30 | if ($classArray[0] == 'NelsonMartell') { |
||
31 | $classArray[0] = 'src'; |
||
32 | } else { |
||
33 | // Only checks for NelsonMartell namespace. |
||
34 | return; |
||
35 | } |
||
36 | |||
37 | $path = sprintf('%s'.$DS.'%s', __DIR__.$DS.'..', implode($DS, $classArray)); |
||
38 | |||
39 | if (is_file($path.'.php')) { |
||
40 | $path .= '.php'; |
||
41 | } elseif (is_file($path.'.inc')) { |
||
42 | $path .= '.inc'; |
||
43 | } else { |
||
44 | $msg = 'Unable to auto-load "%s" class in Nelson Martell Library (NML): "%s" file was not found.'. |
||
1 ignored issue
–
show
|
|||
45 | ' You can see the API documentation (http://nelson6e65.github.io/php_nml/api) in order to check '. |
||
1 ignored issue
–
show
|
|||
46 | ' availability of all classes/namespaces in NML. Note: If you are using "NelsonMartell" as main namespace'. |
||
1 ignored issue
–
show
|
|||
47 | ' in a file that not belongs to NML, you should include it before to load "NML/autoload.php" or,'. |
||
1 ignored issue
–
show
|
|||
48 | ' using SPL autoload features, register autoload function for that class(es) using "prepend" argument for'. |
||
1 ignored issue
–
show
|
|||
49 | ' spl_autoload_register function set to TRUE.'; |
||
50 | |||
51 | throw new Exception(sprintf(dgettext('nml', $msg), $class, $path)); |
||
52 | } |
||
53 | |||
54 | require_once($path); |
||
55 | } |
||
56 |
Learn more about camelCase.