PHPDaemon\HTTPRequest\Generic::parseSize PHP Method

parseSize() public static method

Converts human-readable representation of size to number of bytes
public static parseSize ( string $value ) : integer
$value string String of size
return integer
    public static function parseSize($value)
    {
        $l = substr($value, -1);
        if ($l === 'b' || $l === 'B') {
            return (int) substr($value, 0, -1);
        }
        if ($l === 'k') {
            return (int) substr($value, 0, -1) * 1000;
        }
        if ($l === 'K') {
            return (int) substr($value, 0, -1) * 1024;
        }
        if ($l === 'm') {
            return (int) substr($value, 0, -1) * 1000 * 1000;
        }
        if ($l === 'M') {
            return (int) substr($value, 0, -1) * 1024 * 1024;
        }
        if ($l === 'g') {
            return (int) substr($value, 0, -1) * 1000 * 1000 * 1000;
        }
        if ($l === 'G') {
            return (int) substr($value, 0, -1) * 1024 * 1024 * 1024;
        }
        return (int) $value;
    }