autoload.php 1012 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /* ===========================================================================
  3. * Copyright (c) 2018-2021 Zindex Software
  4. *
  5. * Licensed under the MIT License
  6. * =========================================================================== */
  7. require_once __DIR__ . '/functions.php';
  8. spl_autoload_register(function($class){
  9. $class = ltrim($class, '\\');
  10. $dir = __DIR__ . '/src';
  11. $namespace = 'Opis\Closure';
  12. if(strpos($class, $namespace) === 0)
  13. {
  14. $class = substr($class, strlen($namespace));
  15. $path = '';
  16. if(($pos = strripos($class, '\\')) !== FALSE)
  17. {
  18. $path = str_replace('\\', '/', substr($class, 0, $pos)) . '/';
  19. $class = substr($class, $pos + 1);
  20. }
  21. $path .= str_replace('_', '/', $class) . '.php';
  22. $dir .= '/' . $path;
  23. if(file_exists($dir))
  24. {
  25. include $dir;
  26. return true;
  27. }
  28. return false;
  29. }
  30. return false;
  31. });