code: public static function formatSize(
          int $bytes,
          int $precision = 0,
          string $point = ".",
          string $sep = ","
      ): string
      {
          $i = 0;
          $sizes = ["bytes", "KB", "MB", "GB", "TB", "PB", "EB"];
          while ($bytes > 1024) {
              $bytes /= 1024;
              $i++;
          }
  
          if ($i === 0) {
              $precision = 0;
          }
  
          return number_format($bytes, $precision, $point, $sep)." ".$sizes[$i];
      }
docs: Format a bytesize into a human readable string
  Note: precision will be ignored for results less than a KB
  
  @param int $bytes The number fo bytes to format
  @param int $precision The number of decimal places to round to
  @param string $point Decimal point
  @param string $sep Thousands separator
  @return string