Autoloader.php 939 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /*
  3. * This file is part of Raven.
  4. *
  5. * (c) Sentry Team
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * Autoloads Raven classes.
  12. *
  13. * @package raven
  14. */
  15. class Raven_Autoloader
  16. {
  17. /**
  18. * Registers Raven_Autoloader as an SPL autoloader.
  19. */
  20. public static function register()
  21. {
  22. spl_autoload_register(array('Raven_Autoloader', 'autoload'));
  23. }
  24. /**
  25. * Handles autoloading of classes.
  26. *
  27. * @param string $class A class name.
  28. */
  29. public static function autoload($class)
  30. {
  31. if (substr($class, 0, 6) !== 'Raven_') {
  32. return;
  33. }
  34. $file = dirname(__FILE__).'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php';
  35. if (is_file($file)) {
  36. /** @noinspection PhpIncludeInspection */
  37. require $file;
  38. }
  39. }
  40. }