Test Failed
Push — master ( 712c95...f9640e )
by Alexander
05:49 queued 02:47
created

Installer::copyEnvFile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App;
6
7
use Composer\Script\Event;
8
use FilesystemIterator as FSIterator;
9
use RecursiveDirectoryIterator as DirIterator;
10
use RecursiveIteratorIterator as RIterator;
11
12
final class Installer
13
{
14
    /**
15
     * @psalm-suppress UndefinedClass
16
     */
17
    public static function postUpdate(Event $event = null): void
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

17
    public static function postUpdate(/** @scrutinizer ignore-unused */ Event $event = null): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
18
    {
19
        self::chmodRecursive('runtime', 0777);
20
        self::chmodRecursive('public/assets', 0777);
21
    }
22
23
    private static function chmodRecursive(string $path, int $mode): void
24
    {
25
        chmod($path, $mode);
26
        $iterator = new RIterator(
27
            new DirIterator($path, FSIterator::SKIP_DOTS | FSIterator::CURRENT_AS_PATHNAME),
28
            RIterator::SELF_FIRST
29
        );
30
        foreach ($iterator as $item) {
31
            chmod($item, $mode);
32
        }
33
    }
34
35
    public static function copyEnvFile(): void
36
    {
37
        if (!file_exists('.env')) {
38
            copy('.env.example', '.env');
39
        }
40
    }
41
}
42