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