Passed
Push — master ( 6c42be...776013 )
by Igor
02:03
created

Engine::getLoader()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
nc 2
nop 0
dl 0
loc 19
rs 9.9
c 0
b 0
f 0
1
<?php
2
/**
3
 * Class for Payever API Main Engine
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  API
8
 * @package   Payever\Core
9
 * @author    payever GmbH <[email protected]>
10
 * @copyright 2017-2018 payever GmbH
11
 * @license   MIT <https://opensource.org/licenses/MIT>
12
 * @link      https://getpayever.com/shopsystem/
13
 */
14
15
namespace Payever\ExternalIntegration\Core;
16
17
// @codeCoverageIgnoreStart
18
define('PEI_CORE_VERSION', '2.0.0');
19
define('PEI_CORE_MAJOR_VERSION', 2);
20
define('PEI_CORE_MINOR_VERSION', 0);
21
define('PEI_CORE_RELEASE_VERSION', 0);
22
23
define('PEI_NAMESPACE', 'Payever\ExternalIntegration');
24
25
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
26
    throw new \Exception('payever SDK requires PHP version 5.4 or higher.');
27
}
28
// @codeCoverageIgnoreEnd
29
30
/**
31
 * Class for Payever API Main Engine
32
 *
33
 * PHP version 5.4
34
 *
35
 * @category  API
36
 * @package   Payever\Core
37
 * @author    Andrey Puhovsky <[email protected]>
38
 * @copyright 2017-2018 payever GmbH
39
 * @license   MIT <https://opensource.org/licenses/MIT>
40
 * @link      https://getpayever.com/shopsystem/
41
 */
42
class Engine
43
{
44
    const SDK_VERSION = PEI_CORE_VERSION;
45
46
    protected static $registered = false;
47
48
    public static function registerAutoloader()
49
    {
50
        if (!self::$registered) {
51
            self::$registered = spl_autoload_register(
52
                function ($className) {
53
                    if (strncmp(PEI_NAMESPACE, $className, strlen(PEI_NAMESPACE)) !== 0) {
54
                        return;
55
                    }
56
57
                    $class = substr($className, strlen(PEI_NAMESPACE));
58
59
                    $filePath = __DIR__ . DIRECTORY_SEPARATOR . '..' . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
60
61
                    if (file_exists($filePath)) {
62
                        require_once $filePath;
63
                    }
64
                },
65
                true,
66
                true
67
            );
68
        }
69
    }
70
}
71