| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3.072 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | 2 | public function check() |
|
| 31 | { |
||
| 32 | 2 | $df = disk_free_space($this->path); |
|
| 33 | 2 | $dt = disk_total_space($this->path); |
|
| 34 | |||
| 35 | 2 | $du = $dt - $df; |
|
| 36 | 2 | $dp = round(($du / $dt) * 100, 2); |
|
| 37 | |||
| 38 | 2 | if ($dp >= $this->criticalThreshold) { |
|
| 39 | return new Failure(sprintf('Disk usage too high: %.2f %%.', $dp), $dp); |
||
| 40 | } |
||
| 41 | |||
| 42 | 2 | if ($dp >= $this->warningThreshold) { |
|
| 43 | return new Warning(sprintf('Disk usage high: %.2f %%.', $dp), $dp); |
||
| 44 | } |
||
| 45 | |||
| 46 | 2 | return new Success(sprintf('Disk usage is %.5f %%.', $dp), $dp); |
|
| 47 | } |
||
| 49 |