Export.php ➔ export_env()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 2
dl 0
loc 15
ccs 10
cts 10
cp 1
crap 4
rs 9.7666
c 0
b 0
f 0
1
<?php
2
3
function export_env($from='.env', $to='.env.example')
4
{
5 7
    if(!file_exists($from)) {
6 2
        throw new \Exception("File [$from] not found");
7
    }
8 5
    $files = file($from);
9 5
    $newFile = $to;
10 5
    file_put_contents($newFile, '');
11 5
    foreach ($files as $file) {
12 5
        $key = explode("=", $file)[0];
13 5
        if (empty(trim($key))) continue;
14 5
        file_put_contents($newFile, "$key=" . PHP_EOL, FILE_APPEND);
15
    }
16 5
    return true;
17
}
18