Add configuration for travis-ci.org
[shpub.git] / src / shpub / Autoloader.php
1 <?php
2 /**
3  * Part of shpub
4  *
5  * PHP version 5
6  *
7  * @author  Christian Weiske <cweiske@cweiske.de>
8  * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
9  * @link    http://cweiske.de/shpub.htm
10  */
11 namespace shpub;
12
13 /**
14  * Class autoloader, PSR-0 compliant.
15  *
16  * @author  Christian Weiske <cweiske@cweiske.de>
17  * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
18  * @version Release: @package_version@
19  * @link    http://cweiske.de/shpub.htm
20  */
21 class Autoloader
22 {
23     /**
24      * Load the given class
25      *
26      * @param string $class Class name
27      *
28      * @return void
29      */
30     public function load($class)
31     {
32         $file = strtr($class, '_\\', '//') . '.php';
33         if (stream_resolve_include_path($file)) {
34             include $file;
35         }
36     }
37
38     /**
39      * Register this autoloader
40      *
41      * @return void
42      */
43     public static function register()
44     {
45         set_include_path(
46             get_include_path() . PATH_SEPARATOR . __DIR__ . '/../'
47         );
48         spl_autoload_register(array(new self(), 'load'));
49     }
50 }
51 ?>