comparison vendor/psy/psysh/src/Psy/Autoloader.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 /*
4 * This file is part of Psy Shell.
5 *
6 * (c) 2012-2017 Justin Hileman
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Psy;
13
14 /**
15 * Psy class autoloader.
16 */
17 class Autoloader
18 {
19 /**
20 * Register autoload() as an SPL autoloader.
21 *
22 * @see self::autoload
23 */
24 public static function register()
25 {
26 spl_autoload_register(array(__CLASS__, 'autoload'));
27 }
28
29 /**
30 * Autoload Psy classes.
31 *
32 * @param string $class
33 */
34 public static function autoload($class)
35 {
36 if (0 !== strpos($class, 'Psy')) {
37 return;
38 }
39
40 $file = dirname(__DIR__) . '/' . strtr($class, '\\', '/') . '.php';
41 if (is_file($file)) {
42 require $file;
43 }
44 }
45 }