Autoloader.php 913 B

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