12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace WebDriver;
- final class ClassLoader
- {
-
- public static function loadClass($class)
- {
- $file = strpos($class, '\\') !== false
- ? str_replace('\\', DIRECTORY_SEPARATOR, $class)
- : str_replace('_', DIRECTORY_SEPARATOR, $class);
- $path = dirname(__DIR__) . DIRECTORY_SEPARATOR . $file . '.php';
- if (file_exists($path)) {
- include_once $path;
- }
- }
-
- public static function autoload($class)
- {
- try {
- self::loadClass($class);
- } catch (\Exception $e) {
- }
- }
- }
- if (function_exists('spl_autoload_register')) {
-
- spl_autoload_register(array('WebDriver\ClassLoader', 'autoload'));
-
- if (function_exists('__autoload')) {
- spl_autoload_register('__autoload');
- }
- } else {
-
- function __autoload($class)
- {
- ClassLoader::autoload($class);
- }
- }
|