Completed
Push — master ( 8a3baa...fa7e80 )
by Vuong
01:55
created

RuntimeAutoload.php$0 ➔ __construct()   B

Complexity

Conditions 6
Paths 16

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 0
cts 17
cp 0
rs 8.8817
c 0
b 0
f 0
cc 6
nc 16
nop 0
crap 42
1
<?php
2
/**
3
 * @link https://github.com/vuongxuongminh/yii2-async
4
 * @copyright Copyright (c) 2019 Vuong Xuong Minh
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 *
7
 * @author Vuong Minh <[email protected]>
8
 * @since 1.0.0
9
 *
10
 * Autoload in environment task executable.
11
 */
12
new class
13
{
14
    const AUTOLOAD_PATHS = [
15
        [
16
            __DIR__ . '/../../../autoload.php',
17
            __DIR__ . '/../../autoload.php',
18
            __DIR__ . '/../vendor/autoload.php',
19
            __DIR__ . '/../../vendor/autoload.php'
20
        ],
21
        [
22
            __DIR__ . '/../../../yiisoft/yii2/Yii.php',
23
            __DIR__ . '/../../yiisoft/yii2/Yii.php',
24
            __DIR__ . '/../vendor/yiisoft/yii2/Yii.php',
25
            __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'
26
        ]
27
    ];
28
29
    /**
30
     *  Constructor require an autoload files.
31
     */
32
    public function __construct()
33
    {
34
        if ($appConfigFile = $_SERVER['argv'][3] ?? null) {
35
36
            $appConfig = require($appConfigFile); // require first for define YII_ENV and YII_DEBUG.
37
        }
38
39
        foreach (self::AUTOLOAD_PATHS as $paths) {
40
41
            foreach ($paths as $path) {
42
43
                if (file_exists($path)) {
44
45
                    require($path);
46
47
                    break;
48
                }
49
50
            }
51
        }
52
53
        if (isset($appConfig)) {
54
55
            new \yii\console\Application($appConfig);
56
        }
57
    }
58
};
59
60