Add 'php/phpxmlrpc/' from commit 'cd5dbb4a511e7a616a61187a5de1a611a9748cbd'
[plcapi.git] / php / phpxmlrpc / src / Autoloader.php
diff --git a/php/phpxmlrpc/src/Autoloader.php b/php/phpxmlrpc/src/Autoloader.php
new file mode 100644 (file)
index 0000000..40ec219
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+namespace PhpXmlRpc;
+
+/**
+ * In the unlikely event that you are not using Composer to manage class autoloading, here's an autoloader for this lib.
+ * For usage, see any file in the demo/client directory
+ */
+class Autoloader
+{
+    /**
+     * Registers PhpXmlRpc\Autoloader as an SPL autoloader.
+     *
+     * @param bool $prepend Whether to prepend the autoloader or not.
+     */
+    public static function register($prepend = false)
+    {
+        spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
+    }
+
+    /**
+     * Handles autoloading of classes.
+     *
+     * @param string $class A class name.
+     */
+    public static function autoload($class)
+    {
+        if (0 !== strpos($class, 'PhpXmlRpc\\')) {
+            return;
+        }
+
+        if (is_file($file = __DIR__ . str_replace(array('PhpXmlRpc\\', '\\'), '/', $class).'.php')) {
+            require $file;
+        }
+    }
+}