19 declare(strict_types=1);
    38     public const KiB = 1024;
    39     public const MiB = 1_048_576; 
    40     public const GiB = 1_073_741_824;
    41     public const TiB = 1_099_511_627_776;
    44     public const KB = 1000; 
    45     public const MB = 1_000_000; 
    46     public const GB = 1_000_000_000; 
    47     public const TB = 1_000_000_000_000; 
    89         $this->size = (float) $size / (
float) 
$unit; 
    95         return match ($unit) {
   105             default => 
throw new \InvalidArgumentException(
'The given data size unit is not valid, please check the provided class constants of the DataSize class.')
   143         $unit = match (
true) {
   144             $size > self::SIZE_FACTOR * self::SIZE_FACTOR * self::SIZE_FACTOR * self::SIZE_FACTOR => 
DataSize::TB,
   145             $size > self::SIZE_FACTOR * self::SIZE_FACTOR * self::SIZE_FACTOR => 
DataSize::GB,
   146             $size > self::SIZE_FACTOR * self::SIZE_FACTOR => 
DataSize::MB,
   151         $size = round($size / (
float) $unit, self::PRECISION);
 
mapUnitToSuffix(int $unit)
 
This class provides the data size with additional information to remove the work to calculate the siz...
 
inBytes()
Get the size in bytes. 
 
static array $abbreviations
 
__toString()
Returns the data size in a human readable manner. 
 
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. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...