name = $name; } /** * @return mixed */ public function getUnit() { return $this->unit; } /** * @param mixed $unit * @return Resource */ public function setUnit($unit) { $this->unit = $unit; return $this; } /** * @return mixed */ public function getMin() { return $this->min; } /** * @param mixed $min * @return Resource */ public function setMin($min) { $this->min = $min; return $this; } /** * @return mixed */ public function getMax() { return $this->max; } /** * @param mixed $max * @return Resource */ public function setMax($max) { $this->max = $max; return $this; } /** * @return mixed */ public function getUsed() { return $this->used; } /** * @param mixed $used * @return Resource */ public function setUsed($used) { $this->used = $used; return $this; } /** * @return mixed */ public function getTotal() { return $this->total; } /** * @param mixed $total * @return Resource */ public function setTotal($total) { $this->total = $total; return $this; } public function free(){ $totalUsed = $this->freeTotal(); if($this->max && $this->max < $totalUsed){ return $this->max; } return $totalUsed; } public function freeTotal(){ return $this->total - $this->used; } public function hasFreeTotal(){ return $this->freeTotal() > 0; } public function getPercent(){ if(!$this->total){ return 0; } return round($this->used / $this->total * 100); } }