Completed
Push — master ( bcfe8b...96fd48 )
by Patrick
15s
created

Autoload.php ➔ FlipsideAutoload()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 12

Duplication

Lines 18
Ratio 100 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 3
eloc 12
c 1
b 1
f 0
nc 4
nop 1
dl 18
loc 18
rs 9.4285
1
<?php
2
/**
3
* Flipside Common Code Autoload Function
4
*
5
* Autoload Flipside Common code Classes with the syntax Namespace/class.Classname.php
6
*
7
* @author Patrick Boyd / [email protected]
8
* @copyright Copyright (c) 2015, Austin Artistic Reconstruction
9
* @license http://www.apache.org/licenses/ Apache 2.0 License
10
*/
11
12
/**
13
* Flipside Common Code Autoload Function
14
*
15
* Autoload Flipside Common code Classes with the syntax Namespace/class.Classname.php
16
*
17
* @param string $classname The class name with the namespace to load
18
*/
19 View Code Duplication
function FlipsideAutoload($classname)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    $classname = str_replace('/', '\\', $classname);
22
    $classname = ltrim($classname, '\\');
23
    $filename  = '';
24
    $namespace = '';
25
    if($lastNsPos = strrpos($classname, '\\'))
26
    {
27
        $namespace = substr($classname, 0, $lastNsPos);
28
        $classname = substr($classname, $lastNsPos + 1);
29
        $filename  = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR;
30
    }
31
    $filename = __DIR__.DIRECTORY_SEPARATOR.$filename.'class.'.$classname.'.php';
32
    if(is_readable($filename))
33
    {
34
        require $filename;
35
    }
36
}
37
38 View Code Duplication
if(version_compare(PHP_VERSION, '5.3.0', '>='))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
{
40
    spl_autoload_register('FlipsideAutoload', true, true);
41
}
42
else
43
{
44
    spl_autoload_register('FlipsideAutoload');
45
}
46
/* vim: set tabstop=4 shiftwidth=4 expandtab: */
47