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