<?php

class DiskInfo {
	private $_disk;
	private static $Postfix=["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];

	public function __construct($disk) {
		$this->_disk=$disk;
	}

	public function __get($name) {
		return $this->$name();
	}

	private function HumanSize($bytes) {
		$index=0;
		while ($bytes>=1024) {
			$bytes/=1024;
			$index++;
		}
		return round($bytes, 2).self::$Postfix[$index];
	}

	private function FreeSpace() {
		return $this->HumanSize(disk_free_space($this->_disk));
	}

	private function TotalSpace() {
		return $this->HumanSize(disk_total_space($this->_disk));
	}

	private function PercentageUsed(){
		$free=disk_free_space($this->_disk);
		$total=disk_total_space($this->_disk);
		$remaining=($total-$free)/$total;
		return round($remaining*100,2);
	}
	
	private function Disk(){
		return $this->_disk;
	}
}
