| Conditions | 8 |
| Paths | 6 |
| Total Lines | 29 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | private function getDiskFreeInfo(string $path = '/'): array |
||
| 30 | { |
||
| 31 | $bytesFree = System::getInstance()->getDiskFreeSpace($path); |
||
| 32 | $bytesTotal = System::getInstance()->getDiskTotalSpace($path); |
||
| 33 | |||
| 34 | if ($bytesFree === false || $bytesTotal === false || $bytesTotal == 0) { |
||
|
|
|||
| 35 | return []; |
||
| 36 | } |
||
| 37 | |||
| 38 | $gbFree = round($bytesFree / 1024 / 1024 / 1024, 2); |
||
| 39 | $percentFree = ($bytesFree / $bytesTotal) * 100; |
||
| 40 | $percentFreeRounded = floor($percentFree); // immer abrunden |
||
| 41 | |||
| 42 | if ($percentFreeRounded < 20) { |
||
| 43 | $score = 100; |
||
| 44 | } elseif ($percentFreeRounded < 40) { |
||
| 45 | $score = 75; |
||
| 46 | } elseif ($percentFreeRounded < 60) { |
||
| 47 | $score = 50; |
||
| 48 | } elseif ($percentFreeRounded < 80) { |
||
| 49 | $score = 25; |
||
| 50 | } else { |
||
| 51 | $score = 0; |
||
| 52 | } |
||
| 53 | |||
| 54 | return [ |
||
| 55 | 'gb_free' => $gbFree, |
||
| 56 | 'percent_free' => $percentFreeRounded, |
||
| 57 | 'score' => $score |
||
| 58 | ]; |
||
| 61 |