<?php
namespace edge;
/**
* Class loader
*
*/
class classLoader{
private $pathes=null;
/**
* Constructor
*
* @param array $pathes
* @return void
*/
public function __construct($pathes)
{
if(!is_null($pathes)){
$this->pathes=$pathes;
}
}
/**
* Register
*
* @return void
*/
public function register()
{
spl_autoload_register(array($this,"load"));
}
/**
* Unregister
*
* @return void
*/
public function unregister()
{
spl_autoload_unregister(array($this,"load"));
}
/**
* Load
*
* @param string $class
* @return void
*/
public function load($class)
{
if(!is_null($this->pathes)){
$class=str_replace(array_keys($this->pathes),array_values($this->pathes),$class);
}
if(strpos($class,"\\")!==false){
$class=str_replace("\\","/",$class);
}
$file=$class . ".php";
if(file_exists($file)){
include $file;
}
}
}