This repository has been archived by the owner on Nov 8, 2023. It is now read-only.
forked from Mac2/libiwparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoloaderC.php
72 lines (60 loc) · 2.3 KB
/
AutoloaderC.php
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <[email protected]> wrote this file. As long as you retain
* this notice you can do whatever you want with this stuff. If we meet some
* day, and you think this stuff is worth it, you can buy me a beer in return.
* Benjamin Wöster
* ----------------------------------------------------------------------------
*/
/**
* @author Benjamin Wöster <[email protected]>
* @package libIwParsers
* @subpackage helpers
*/
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
class AutoloaderC
{
static private $_instance = null;
private $_aPathes = array();
///////////////////////////////////////////////////////////////////////
/**
* Returns an instance of the factory.
*
* @return instance of the factory.
*/
static private function getInstance()
{
if (self::$_instance === null) {
self::$_instance = new AutoloaderC();
}
return self::$_instance;
}
///////////////////////////////////////////////////////////////////////
static public function addPath($pathName)
{
$instance = AutoloaderC::getInstance();
if (is_dir($pathName)
&& in_array($pathName, $instance->_aPathes) === false
) {
$instance->_aPathes[] = $pathName;
}
}
///////////////////////////////////////////////////////////////////////
static public function load($className)
{
$instance = AutoloaderC::getInstance();
foreach ($instance->_aPathes as $path) {
if (file_exists($path . DIRECTORY_SEPARATOR . $className . '.php')) {
//the load-method will only be called for classes that haven't
//been defined. So there should be no need for require_once.
//Hopefully this gives a bit more speed.
require($path . DIRECTORY_SEPARATOR . $className . '.php');
break;
}
}
}
}