Passed
Push — master ( 30a216...657feb )
by Alexander
04:20
created

shouldRebuildConfigs()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 7
c 1
b 1
f 0
nc 2
nop 0
dl 0
loc 11
ccs 6
cts 7
cp 0.8571
crap 2.0116
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
use Yiisoft\Files\FileHelper;
6
use Yiisoft\VarDumper\VarDumper;
7
8
function shouldRebuildConfigs(): bool {
9 10
    $sourceDirectory = dirname(__DIR__) . '/config/';
10 10
    $buildDirectory = dirname(__DIR__) . '/runtime/build/config/';
11
12 10
    if (FileHelper::isEmptyDirectory($buildDirectory)) {
13
        return true;
14
    }
15
16 10
    $sourceTime = FileHelper::lastModifiedTime($sourceDirectory);
17 10
    $buildTime = FileHelper::lastModifiedTime($buildDirectory);
18 10
    return $buildTime < $sourceTime;
19
}
20
21
if (!function_exists('d')) {
22
    function d(...$variables)
23
    {
24
        foreach ($variables as $variable) {
25
            VarDumper::dump($variable, 10, PHP_SAPI !== 'cli');
26
        }
27
    }
28
}
29
30
if (!function_exists('dd')) {
31
    function dd(...$variables)
32
    {
33
        foreach ($variables as $variable) {
34
            VarDumper::dump($variable, 10, PHP_SAPI !== 'cli');
35
        }
36
        die();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
37
    }
38
}
39