Autoload   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 35
ccs 0
cts 13
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 5 1
A classLoader() 0 16 2
1
<?php
2
namespace Toolshedr;
3
/**
4
 * Class Autoload
5
 * @package Toolshedr
6
 */
7
final class Autoload
8
{
9
    private $root_path;
10
11
    /**
12
     * Toolshedr constructor.
13
     */
14
    public function register()
15
    {
16
        $this->root_path = dirname(__FILE__);
17
        spl_autoload_register(array($this, 'classLoader'));
18
    }
19
20
    /**
21
     * The Autoloader
22
     *
23
     * @param bool $class
24
     */
25
    public function classLoader($class = false)
26
    {
27
        $relative_path = preg_replace(array(
28
            '/Toolshedr/',
29
            '/\\\\/'
30
        ), array(
31
            '',
32
            DIRECTORY_SEPARATOR
33
        ), $class);
34
        
35
        $class_file = $this->root_path.$relative_path.'.php';
36
37
        if (file_exists($class_file)) {
38
            require_once $class_file;
39
        }
40
    }
41
}
42