| @@ -1,26 +1,26 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -spl_autoload_register( | |
| 4 | - function ( $class ) { | |
| 5 | - // project-specific namespace prefix | |
| 6 | - $prefix = 'FL\\Assistant\\'; | |
| 7 | - // base directory for the namespace prefix | |
| 8 | - $base_dir = trailingslashit( sprintf( '%s/src/', __DIR__ ) ); | |
| 9 | - // does the class use the namespace prefix? | |
| 10 | - $len = strlen( $prefix ); | |
| 11 | - if ( strncmp( $prefix, $class, $len ) !== 0 ) { | |
| 12 | - // no, move to the next registered autoloader | |
| 13 | - return; | |
| 14 | - } | |
| 15 | - // get the relative class name | |
| 16 | - $relative_class = substr( $class, $len ); | |
| 17 | - // replace the namespace prefix with the base directory, replace namespace | |
| 18 | - // separators with directory separators in the relative class name, append with .php | |
| 19 | - $file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php'; | |
| 20 | - // if the file exists, require it | |
| 21 | - if ( file_exists( $file ) ) { | |
| 22 | - /** @noinspection PhpIncludeInspection */ | |
| 23 | - require $file; | |
| 24 | - } | |
| 25 | - } | |
| 26 | -); | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +spl_autoload_register( | |
| 4 | + function ( $class ) { | |
| 5 | + // project-specific namespace prefix | |
| 6 | + $prefix = 'FL\\Assistant\\'; | |
| 7 | + // base directory for the namespace prefix | |
| 8 | + $base_dir = trailingslashit( sprintf( '%s/src/', __DIR__ ) ); | |
| 9 | + // does the class use the namespace prefix? | |
| 10 | + $len = strlen( $prefix ); | |
| 11 | + if ( strncmp( $prefix, $class, $len ) !== 0 ) { | |
| 12 | + // no, move to the next registered autoloader | |
| 13 | + return; | |
| 14 | + } | |
| 15 | + // get the relative class name | |
| 16 | + $relative_class = substr( $class, $len ); | |
| 17 | + // replace the namespace prefix with the base directory, replace namespace | |
| 18 | + // separators with directory separators in the relative class name, append with .php | |
| 19 | + $file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php'; | |
| 20 | + // if the file exists, require it | |
| 21 | + if ( file_exists( $file ) ) { | |
| 22 | + /** @noinspection PhpIncludeInspection */ | |
| 23 | + require $file; | |
| 24 | + } | |
| 25 | + } | |
| 26 | +); | |