100 || $warningThreshold < 0) { throw new InvalidArgumentException('Invalid warningThreshold argument - expecting an integer between 1 and 100'); } if ($criticalThreshold > 100 || $criticalThreshold < 0) { throw new InvalidArgumentException('Invalid criticalThreshold argument - expecting an integer between 1 and 100'); } $this->warningThreshold = (int) $warningThreshold; $this->criticalThreshold = (int) $criticalThreshold; $this->path = $path; } /** * Perform the check * * @return Failure|Success|Warning */ public function check() { $df = disk_free_space($this->path); $dt = disk_total_space($this->path); $du = $dt - $df; $dp = ($du / $dt) * 100; if ($dp >= $this->criticalThreshold) { return new Failure(sprintf('Disk usage too high: %2d percent.', $dp)); } if ($dp >= $this->warningThreshold) { return new Warning(sprintf('Disk usage high: %2d percent.', $dp)); } return new Success(sprintf('Disk usage is %2d percent.', $dp)); } }