Engine   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 18
c 1
b 0
f 0
dl 0
loc 34
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A registerAutoloader() 0 24 4
1
<?php
2
3
/**
4
 * Class for Payever API Main Engine
5
 *
6
 * PHP version 5.4 and 8
7
 *
8
 * @category  API
9
 * @package   Payever\Core
10
 * @author    payever GmbH <[email protected]>
11
 * @copyright 2017-2021 payever GmbH
12
 * @license   MIT <https://opensource.org/licenses/MIT>
13
 * @link      https://docs.payever.org/shopsystems/api/getting-started
14
 */
15
16
namespace Payever\ExternalIntegration\Core;
17
18
// @codeCoverageIgnoreStart
19
// phpcs:disable PSR1.Files.SideEffects
20
define('PEI_CORE_VERSION', '4.7.1');
21
define('PEI_CORE_MAJOR_VERSION', 4);
22
define('PEI_CORE_MINOR_VERSION', 7);
23
define('PEI_CORE_RELEASE_VERSION', 1);
24
25
define('PEI_NAMESPACE', 'Payever\ExternalIntegration');
26
27
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
28
    throw new \RuntimeException('payever SDK requires PHP version 5.4 or higher.');
29
}
30
// @codeCoverageIgnoreEnd
31
// phpcs:enable PSR1.Files.SideEffects
32
33
/**
34
 * Class for Payever API Main Engine
35
 */
36
class Engine
37
{
38
    const SDK_VERSION = PEI_CORE_VERSION;
39
40
    /** @var bool */
41
    protected static $registered = false;
42
43
    /**
44
     * @retrun void
45
     */
46
    public static function registerAutoloader()
47
    {
48
        if (!self::$registered) {
49
            self::$registered = spl_autoload_register(
50
                function ($className) {
51
                    if (strncmp(PEI_NAMESPACE, $className, strlen(PEI_NAMESPACE)) !== 0) {
52
                        return;
53
                    }
54
55
                    $class = substr($className, strlen(PEI_NAMESPACE));
56
57
                    $filePath = sprintf(
58
                        '%s%s..%s.php',
59
                        __DIR__,
60
                        DIRECTORY_SEPARATOR,
61
                        str_replace('\\', DIRECTORY_SEPARATOR, $class)
62
                    );
63
64
                    if (file_exists($filePath)) {
65
                        require_once $filePath;
66
                    }
67
                },
68
                true,
69
                true
70
            );
71
        }
72
    }
73
}
74