-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoload.php
More file actions
48 lines (42 loc) · 810 Bytes
/
autoload.php
File metadata and controls
48 lines (42 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
*
* @author Enrique Piatti (contacto@enriquepiatti.com)
*/
class Autoloader
{
static protected $_instance;
/**
* Singleton pattern implementation
*
* @return Autoloader
*/
static public function instance()
{
if (!self::$_instance) {
self::$_instance = new Autoloader();
}
return self::$_instance;
}
/**
* Register SPL autoload function
*/
static public function register()
{
spl_autoload_register(array(self::instance(), 'autoload'));
}
/**
* Load class source code
*
* @param string $class
* @return mixed
*/
public function autoload($class)
{
$classFile = str_replace(' ', DIRECTORY_SEPARATOR, ucwords(str_replace('_', ' ', $class)));
$classFile.= '.php';
//echo $classFile;die();
return include $classFile;
}
}
Autoloader::register();