PHP Classes

File: autoload.php

Recommend this page to a friend!
  Classes of Kjell-Inge Gustafsson   Asit PHP Collection Class   autoload.php   Download  
File: autoload.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Asit PHP Collection Class
Manages collections of elements stored in arrays
Author: By
Last change: 1.2
Date: 4 years ago
Size: 1,548 bytes
 

Contents

Class file image Download
<?php
/**
 * Asit package manages array collections
 *
 * Copyright 2020 Kjell-Inge Gustafsson, kigkonsult, All rights reserved
 * Link <https://kigkonsult.se>
 * Support <https://github.com/iCalcreator/Asit>
 *
 * This file is part of Asit.
 *
 * Asit is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * Asit is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Asit. If not, see <https://www.gnu.org/licenses/>.
 */
/**
 * Kigkonsult\Asit autoloader
 */
spl_autoload_register(
    function(
$class ) {
        static
$PREFIX = 'Kigkonsult\\Asit\\';
        static
$BS = '\\';
        static
$SRC = 'src';
        static
$PHP = '.php';
        if (
0 != strncmp( $PREFIX, $class, 16 )) {
            return;
        }
       
$class = substr( $class, 16 );
        if (
false !== strpos( $class, $BS )) {
           
$class = str_replace( $BS, DIRECTORY_SEPARATOR, $class );
        }
       
$file = __DIR__ . DIRECTORY_SEPARATOR . $SRC . DIRECTORY_SEPARATOR . $class . $PHP;
        if (
is_file( $file )) {
            include
$file;
        }
    }
);