Passed
Push — master ( de185f...13345c )
by Nils
02:30
created

System::getInstance()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Startwind\Inventorio\Exec;
4
5
class System
6
{
7
    private static ?System $instance = null;
8
9
    static public function getInstance(): System
10
    {
11
        if (self::$instance === null) {
12
            self::$instance = new self();
13
        }
14
15
        return self::$instance;
0 ignored issues
show
Bug Best Practice introduced by
The expression return self::instance could return the type null which is incompatible with the type-hinted return Startwind\Inventorio\Exec\System. Consider adding an additional type-check to rule them out.
Loading history...
16
    }
17
18
    public function getDiskTotalSpace($directory): float
19
    {
20
        return disk_total_space($directory);
21
    }
22
23
    public function getDiskFreeSpace($directory): float
24
    {
25
        return disk_free_space($directory);
26
    }
27
28
    public function getLoadAverage(): array
29
    {
30
        return sys_getloadavg();
31
    }
32
33
    public function getEnvironmentVariable($name): string
34
    {
35
        return getenv($name);
36
    }
37
}
38