This function to change numeric value to it binary string
and to get the file size.

@false  integer

@param  $fileSize

@return unknown
--------------------------------------------------------
974089
private function fileSize($fileSize)
    {
        if (isNumeric($fileSize)) {
            $decr = 1024;
            $step = 0;

            while (($fileSize / $decr) > 0.9) {
                $fileSize = $fileSize / $decr;
                $step++;
            }

            return round($fileSize, 2).' '.strtoupper($this->_prefix[$step]);
        } else {
            return 'NaN';
        }
    }
858510
private function verifyFileSize($size)
    {
        $max = $this->config['max_size'];
        if ($max > 0 && $size > $max) {
            throw FileSizeException::fileIsTooBig($size, $max);
        }

        return $size;
    }
696460
protected function getByteSize($size)
    {
        if (! preg_match('/(\d+)\s*([tgkmbi]{1,3})/i', $size, $result)) {
            return $size;
        }

        $mapping = $this->mapping[strtolower($result[2])];
        return pow($mapping[0], $mapping[1]) * $result[1];
    }
1276862
public function setMinFileSize(int $minFileSize)
    {
        if ($minFileSize > 0) {
            $properties = $this->getProperties();
            $properties['minFileSize'] = $minFileSize;
            $this->setProperties($properties);
            return $this;
        }
        return false;
    }
84511
private function convertToBytes($strSize)
    {
        switch (strtolower(substr($strSize, - 1))) {
            case 'm':
                return (int) $strSize * 1048576;
            case 'k':
                return (int) $strSize * 1024;
            case 'g':
                return (int) $strSize * 1073741824;
            default:
                return $strSize;
        }
    }
1149850
public function setSize($size)
    {
        if (strpos($size, 'col-') === false) {
            $size = 'col-'.$size.'-';
        }

        $this->size = $size;

        return $this;
    }
882924
public static function sizeCount($filesize)
    {
        if ($filesize >= 1073741824)
        {
            $filesize = round($filesize / 1073741824 * 100) / 100 . ' GB';
        }
        elseif ($filesize >= 1048576)
        {
            $filesize = round($filesize / 1048576 * 100) / 100 . ' MB';
        }
        elseif ($filesize >= 1024)
        {
            $filesize = round($filesize / 1024 * 100) / 100 . ' KB';
        }
        else
        {
            $filesize = $filesize . ' Bytes';
        }
        return $filesize;
    }
386346
function _size($filename)
    {
        $result = $this->_stat($filename, NET_SFTP_LSTAT);
        if ($result === false) {
            return false;
        }
        return isset($result['size']) ? $result['size'] : -1;
    }
1167899
public static function filesize($bytes)
    {
        $precision = (($bytes % 1024) === 0 || $bytes <= 1024) ? 0 : 1;

        $formatter = new ByteSize\Formatter\Binary();
        $formatter->setPrecision($precision);

        return $formatter->format($bytes);
    }
540314
public function setFileSize($size)
    {
        if ($size === null) {
            $this->fileSize = null;

            return $this;
        }

        if (!is_numeric($size)) {
            throw new InvalidArgumentException('File size must be an integer or a float.');
        }

        $this->fileSize = $size;

        return $this;
    }
579583
public static function convertUnitFileSize($size)
    {
        $units = [" B", " KB", " MB", " GB"];
        $calculatedSize = $size;
        $unit = Arrays::first($units);
        if ($size) {
            $calculatedSize = round($size / pow(1024, ($i = (int)floor(log($size, 1024)))), 2);
            $unit = $units[$i];
        }
        return $calculatedSize . $unit;
    }
356346
private function humanFileSize(int $size): string
    {
        if ($size >= 1 << 30) {
            return number_format($size / (1 << 30), 1) . "G";
        }

        if ($size >= 1 << 20) {
            return number_format($size / (1 << 20), 1) . "M";
        }
        if ($size >= 1 << 10) {
            return number_format($size / (1 << 10), 1) . "K";
        }

        return $size;
    }
1083648
public function toReadableSize($size) {

		switch (true) {
			case $size < 1024:
				return __dn('cake', '%d Byte', '%d Bytes', $size, $size);
			case round($size / 1024) < 1024:
				return __d('cake', '%s KB', $this->precision($size / 1024, 0));
			case round($size / 1024 / 1024, 2) < 1024:
				return __d('cake', '%s MB', $this->precision($size / 1024 / 1024, 2));
			case round($size / 1024 / 1024 / 1024, 2) < 1024:
				return __d('cake', '%s GB', $this->precision($size / 1024 / 1024 / 1024, 2));
			default:
				return __d('cake', '%s TB', $this->precision($size / 1024 / 1024 / 1024 / 1024, 2));
		}

	}
275229
public function size($iSize = null)
    {
        if (null === $iSize) {
            return $this->getSize();
        }

        return $this->setSize($iSize);
    }
315814
public static function toInt($size) {
    // Remove the non-unit characters from the size.
    $unit = preg_replace('/[^bkmgtpezy]/i', '', $size);
    // Remove the non-numeric characters from the size.
    $size = preg_replace('/[^0-9\.]/', '', $size);
    if ($unit) {
      // Find the position of the unit in the ordered string which is the power
      // of magnitude to multiply a kilobyte by.
      return round($size * pow(self::KILOBYTE, stripos('bkmgtpezy', $unit[0])));
    }
    else {
      return round($size);
    }
  }
227510
public function allocate($filesize)
    {
        $result = @ftp_alloc($this->connection, $filesize);
        
        if ($result === false) {
            throw new Exception('Unable to allocate');
        }

        return $this;
    }
1019479
public static function convertHumanFileSizeToBytes($file_size)
    {
        $file_size = str_replace(
            array(' MB', ' KB', ' bytes'),
            array('M', 'K', 'B'),
            trim($file_size)
        );

        $last = strtolower($file_size[strlen($file_size)-1]);

        $file_size = (int) $file_size;

        switch ($last) {
            case 'g':
                $file_size *= 1024;
            case 'm':
                $file_size *= 1024;
            case 'k':
                $file_size *= 1024;
        }

        return $file_size;
    }