Passed
Push — master ( 8a6050...5a6ead )
by Andrii
11:18
created

Sys::chmod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
namespace hidev\helpers;
4
5
class Sys
6
{
7
    public static function mkdir(string $dir)
8
    {
9
        self::passthru("mkdir -p $dir");
10
    }
11
12
    public static function chmod($mode, $path)
13
    {
14
        self::passthru("sudo chmod $mode $path");
15
    }
16
17
    public static function passthru(string $cmd)
18
    {
19
        echo "> $cmd\n";
20
        $res = \passthru($cmd, $exitcode);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $res is correct as passthru($cmd, $exitcode) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
The assignment to $res is dead and can be removed.
Loading history...
21
        if ($exitcode) {
22
            echo "! failed $cmd";
23
        }
24
    }
25
}
26