22 const GiB = 1073741824;
23 const TiB = 1099511627776;
24 const PiB = 1125899906842624;
25 const EiB = 1152921504606846976;
26 const ZiB = 1180591620717411303424;
27 const YiB = 1208925819614629174706176;
32 const GB = 1000000000;
33 const TB = 1000000000000;
34 const PB = 1000000000000000;
35 const EB = 1000000000000000000;
36 const ZB = 1000000000000000000000;
37 const YB = 1000000000000000000000000;
128 if (!isset(self::$suffixMap[$unit])) {
129 throw new \InvalidArgumentException(
'The given data size unit is not valid, please check the provided class constants of the DataSize class.');
132 $this->size = (float) $size / $unit;
134 $this->suffix = self::$suffixMap[
$unit];
180 return "{$this->size} {$this->suffix}";
inBytes()
Get the size in bytes.
__toString()
Returns the data size with the corresponding suffix.
getSize()
The calculated data size.
getUnit()
The unit which equals the class constant used to calculate the data size.
__construct(int $size, int $unit)
DataSize constructor.