Newer
Older
/**
* Represents the time evolution of a single partition.
*/
class PartitionDelta
{
private $start;
private $end;
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
if ($start->filesystem !== $end->filesystem) {
throw new \Exception("Comparing different filesystems!");
}
$this->start = $start;
$this->end = $end;
}
public function filesystem() : string
{
return $this->start->filesystem;
}
/**
* Return difference of the number of used blocks.
* @return int
*/
public function deltaBlocks() : int
{
return $this->end->used - $this->start->used;
}
/**
* Return time difference between 2 partitions
* @return int
*/
public function deltaT() : int
{
return $this->end->time - $this->start->time;
}
/**
* Time in second, before this partition gets full.
* @return int
*/
public function timeUntillFull() : int
{
if ($this->deltaBlocks() <= 0) {
return PHP_INT_MAX;
}
return ($this->end->blocks - $this->end->used) / $this->deltaBlocks()
* $this->deltaT();
public function timeUntilFullForHumans() : string
{
return Carbon::createFromTimeStamp($this->timeUntillFull())->diffForHumans();