Login   Register  
PHP Classes
elePHPant
Icontem

File: autoload.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of AlexanderC  >  AOPHP  >  autoload.php  >  Download  
File: autoload.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: AOPHP
Alter the behavior of classes with AOP
Author: By
Last change:
Date: 10 months ago
Size: 667 bytes
 

Contents

Class file image Download
<?php
/**
 * @author AlexanderC <self@alexanderc.me>
 * @date 10/28/13
 * @time 8:21 PM
 */

spl_autoload_register(function ($class) {
    
$rawParts explode("\\"$class);

    if (
count($rawParts) <= 0) {
        return 
false;
    }

    if (
$rawParts[0] == "AOPHP") {
        
$path __DIR__ '/src/';
        
$parts $rawParts;

        
$file realpath($path implode("/"$parts) . ".php");

        return 
is_file($file) ? require $file false;
    } else {
        
$path __DIR__ '/tests/';
        
$parts = & $rawParts;
        
$file realpath($path implode("/"$parts) . ".php");

        return 
is_file($file) ? require $file false;
    }
});