autoload.php 734 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Simple PSR-4 autoloader
  4. * @param string $class Class name
  5. */
  6. spl_autoload_register(function($class) {
  7. // Package namespace
  8. $prefix = 'Fr\\RetailMeNot\\Cloud\\StateMachine\\';
  9. // Source folder
  10. $src = dirname(__FILE__).'/src/';
  11. // Does the class use the namespace prefix ?
  12. $len = strlen($prefix);
  13. // If no, move to next autoloader ...
  14. if (strncmp($prefix, $class, $len) !== 0) {
  15. return;
  16. }
  17. // Get relative class name
  18. $relative = substr($class, $len);
  19. // Build class path
  20. $file = $src.str_replace('\\', DIRECTORY_SEPARATOR, $relative).'.php';
  21. // If the file exists, require once it
  22. if (file_exists($file)) {
  23. require_once $file;
  24. }
  25. });