| Conditions | 3 |
| Paths | 3 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | public function getDiskStats(string $directory): array |
||
| 12 | { |
||
| 13 | $disk = []; |
||
| 14 | |||
| 15 | $free = disk_free_space($directory); |
||
| 16 | if ($free === false) { |
||
| 17 | throw new Exception("Couldn't discover free disk space"); |
||
| 18 | } |
||
| 19 | |||
| 20 | $total = disk_total_space($directory); |
||
| 21 | if ($total === false) { |
||
| 22 | throw new Exception("Couldn't discover free disk total space"); |
||
| 23 | } |
||
| 24 | |||
| 25 | $disk['free'] = $free; |
||
| 26 | $disk['total'] = $total; |
||
| 27 | $disk['used'] = $disk['total'] - $disk['free']; |
||
| 28 | $disk['percent'] = $disk['used'] / $disk['total']; |
||
| 29 | return $disk; |
||
| 30 | } |
||
| 32 |