Completed
Push — master ( d6addb...f5f8b9 )
by Patrick
03:38
created

Autoload.php ➔ FlipsideAutoload()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 12

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 12
nc 4
nop 1
dl 18
loc 18
rs 9.4285
c 0
b 0
f 0
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
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
48