Autoloader   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 25
ccs 5
cts 8
cp 0.625
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 3 1
A autoload() 0 8 3
1
<?php
2
3
namespace PhpXmlRpc;
4
5
/**
6
 * In the unlikely event that you are not using Composer to manage class autoloading, here's an autoloader for this lib.
7
 * For usage, see any file in the demo/client directory
8
 */
9
class Autoloader
10
{
11
    /**
12
     * Registers PhpXmlRpc\Autoloader as an SPL autoloader.
13
     *
14
     * @param bool $prepend Whether to prepend the autoloader or not.
15
     */
16
    public static function register($prepend = false)
17
    {
18
        spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
19
    }
20
21
    /**
22
     * Handles autoloading of classes.
23
     *
24
     * @param string $class A class name.
25
     */
26 569
    public static function autoload($class)
27
    {
28 569
        if (0 !== strpos($class, 'PhpXmlRpc\\')) {
29 559
            return;
30
        }
31
32 569
        if (is_file($file = __DIR__ . str_replace(array('PhpXmlRpc\\', '\\'), '/', $class).'.php')) {
33 569
            require $file;
34
        }
35 569
    }
36
}
37