9 * This source file is subject to the new BSD license that is bundled
10 * with this package in the file LICENSE.
11 * It is also available through the world-wide-web at this URL:
12 * http://phergie.org/license
16 * @author Phergie Development Team <team@phergie.org>
17 * @copyright 2008-2010 Phergie Development Team (http://phergie.org)
18 * @license http://phergie.org/license New BSD License
19 * @link http://pear.phergie.org/package/Phergie
23 * Autoloader for Phergie classes.
27 * @author Phergie Development Team <team@phergie.org>
28 * @license http://phergie.org/license New BSD License
29 * @link http://pear.phergie.org/package/Phergie
31 class Phergie_Autoload
34 * Constructor to add the base Phergie path to the include_path.
38 public function __construct()
40 $path = dirname(__FILE__);
41 $includePath = get_include_path();
42 $includePathList = explode(PATH_SEPARATOR, $includePath);
43 if (!in_array($path, $includePathList)) {
49 * Autoload callback for loading class files.
51 * @param string $class Class to load
55 public function load($class)
57 if (substr($class, 0, 8) == 'Phergie_') {
58 $class = substr($class, 8);
60 include str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
64 * Registers an instance of this class as an autoloader.
68 public static function registerAutoloader()
70 spl_autoload_register(array(new self, 'load'));
74 * Add a path to the include path.
76 * @param string $path Path to add
80 public static function addPath($path)
82 set_include_path($path . PATH_SEPARATOR . get_include_path());