|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * responsive-images-css |
| 5 | + * |
| 6 | + * @category Jkphl |
| 7 | + * @package Jkphl\Respimgcss |
| 8 | + * @author Joschi Kuphal <[email protected]> / @jkphl |
| 9 | + * @copyright Copyright © 2018 Joschi Kuphal <[email protected]> / @jkphl |
| 10 | + * @license http://opensource.org/licenses/MIT The MIT License (MIT) |
| 11 | + */ |
| 12 | + |
| 13 | +/*********************************************************************************** |
| 14 | + * The MIT License (MIT) |
| 15 | + * |
| 16 | + * Copyright © 2018 Joschi Kuphal <[email protected]> / @jkphl |
| 17 | + * |
| 18 | + * Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 19 | + * this software and associated documentation files (the "Software"), to deal in |
| 20 | + * the Software without restriction, including without limitation the rights to |
| 21 | + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
| 22 | + * the Software, and to permit persons to whom the Software is furnished to do so, |
| 23 | + * subject to the following conditions: |
| 24 | + * |
| 25 | + * The above copyright notice and this permission notice shall be included in all |
| 26 | + * copies or substantial portions of the Software. |
| 27 | + * |
| 28 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 29 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 30 | + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 31 | + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 32 | + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 33 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 34 | + ***********************************************************************************/ |
| 35 | + |
| 36 | +/** |
| 37 | + * Register a minimal PSR-4 compatible autoloader |
| 38 | + * |
| 39 | + * @see http://www.php-fig.org/psr/psr-4/ |
| 40 | + */ |
| 41 | +spl_autoload_register( |
| 42 | + function ($class) { |
| 43 | + $namespace = 'Jkphl'; |
| 44 | + $prefixes = [ |
| 45 | + "{$namespace}\\" => [ |
| 46 | + __DIR__.'/src', |
| 47 | + ], |
| 48 | + ]; |
| 49 | + foreach ($prefixes as $prefix => $dirs) { |
| 50 | + $prefixLength = strlen($prefix); |
| 51 | + if (substr($class, 0, $prefixLength) !== $prefix) { |
| 52 | + continue; |
| 53 | + } |
| 54 | + $class = substr($class, $prefixLength); |
| 55 | + $part = str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php'; |
| 56 | + foreach ($dirs as $dir) { |
| 57 | + $dir = str_replace('/', DIRECTORY_SEPARATOR, $dir); |
| 58 | + $file = $dir.DIRECTORY_SEPARATOR.$part; |
| 59 | + if (is_readable($file)) { |
| 60 | + require $file; |
| 61 | + return; |
| 62 | + } |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | +); |
0 commit comments