Completed
Pull Request — master (#63)
by Abdelouahab
08:25 queued 10s
created

loadClassLoader()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
// autoload_real.php @generated by Composer
4
5
class ComposerAutoloaderInit721cd3db612b8dbb6d16a455d6d11e8d
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    private static $loader;
8
9
    public static function loadClassLoader($class)
10
    {
11
        if ('Composer\Autoload\ClassLoader' === $class) {
12
            require __DIR__ . '/ClassLoader.php';
13
        }
14
    }
15
16
    public static function getLoader()
17
    {
18
        if (null !== self::$loader) {
19
            return self::$loader;
20
        }
21
22
        spl_autoload_register(array('ComposerAutoloaderInit721cd3db612b8dbb6d16a455d6d11e8d', 'loadClassLoader'), true, true);
23
        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
        spl_autoload_unregister(array('ComposerAutoloaderInit721cd3db612b8dbb6d16a455d6d11e8d', 'loadClassLoader'));
25
26
        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
        if ($useStaticLoader) {
28
            require_once __DIR__ . '/autoload_static.php';
29
30
            call_user_func(\Composer\Autoload\ComposerStaticInit721cd3db612b8dbb6d16a455d6d11e8d::getInitializer($loader));
31
        } else {
32
            $map = require __DIR__ . '/autoload_namespaces.php';
33
            foreach ($map as $namespace => $path) {
34
                $loader->set($namespace, $path);
35
            }
36
37
            $map = require __DIR__ . '/autoload_psr4.php';
38
            foreach ($map as $namespace => $path) {
39
                $loader->setPsr4($namespace, $path);
40
            }
41
42
            $classMap = require __DIR__ . '/autoload_classmap.php';
43
            if ($classMap) {
44
                $loader->addClassMap($classMap);
45
            }
46
        }
47
48
        $loader->register(true);
49
50
        if ($useStaticLoader) {
51
            $includeFiles = Composer\Autoload\ComposerStaticInit721cd3db612b8dbb6d16a455d6d11e8d::$files;
52
        } else {
53
            $includeFiles = require __DIR__ . '/autoload_files.php';
54
        }
55
        foreach ($includeFiles as $fileIdentifier => $file) {
56
            composerRequire721cd3db612b8dbb6d16a455d6d11e8d($fileIdentifier, $file);
57
        }
58
59
        return $loader;
60
    }
61
}
62
63
function composerRequire721cd3db612b8dbb6d16a455d6d11e8d($fileIdentifier, $file)
0 ignored issues
show
Coding Style introduced by
composerRequire721cd3db612b8dbb6d16a455d6d11e8d uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
64
{
65
    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
        require $file;
67
68
        $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
69
    }
70
}
71