Add 'php/phpxmlrpc/' from commit 'cd5dbb4a511e7a616a61187a5de1a611a9748cbd'
[plcapi.git] / php / phpxmlrpc / src / Autoloader.php
1 <?php
2
3 namespace PhpXmlRpc;
4
5 /**
6  * In the unlikely event that you are not using Composer to manage class autoloading, here's an autoloader for this lib.
7  * For usage, see any file in the demo/client directory
8  */
9 class Autoloader
10 {
11     /**
12      * Registers PhpXmlRpc\Autoloader as an SPL autoloader.
13      *
14      * @param bool $prepend Whether to prepend the autoloader or not.
15      */
16     public static function register($prepend = false)
17     {
18         spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
19     }
20
21     /**
22      * Handles autoloading of classes.
23      *
24      * @param string $class A class name.
25      */
26     public static function autoload($class)
27     {
28         if (0 !== strpos($class, 'PhpXmlRpc\\')) {
29             return;
30         }
31
32         if (is_file($file = __DIR__ . str_replace(array('PhpXmlRpc\\', '\\'), '/', $class).'.php')) {
33             require $file;
34         }
35     }
36 }