summaryrefslogtreecommitdiff
path: root/app/Core/Loader.php
blob: 7c437654995d9d684d7d9ff44cf6427a996b5a9c (plain)
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
<?php

namespace Core;

/**
 * Loader class
 *
 * @package core
 * @author  Frederic Guillot
 */
class Loader
{
    /**
     * Load the missing class
     *
     * @access public
     * @param  string   $class   Class name
     */
    public function load($class)
    {
        $filename = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';

        if (file_exists($filename)) {
            require $filename;
        }
    }

    /**
     * Register the autoloader
     *
     * @access public
     */
    public function execute()
    {
        spl_autoload_register(array($this, 'load'));
    }
}