Respect\Validation\Rules\Size::toBytes PHP Method

toBytes() private method

private toBytes ( mixed $size ) : integer
$size mixed
return integer
    private function toBytes($size)
    {
        $value = $size;
        $units = ['b', 'kb', 'mb', 'gb', 'tb', 'pb', 'eb', 'zb', 'yb'];
        foreach ($units as $exponent => $unit) {
            if (!preg_match("/^(\\d+(.\\d+)?){$unit}\$/i", $size, $matches)) {
                continue;
            }
            $value = $matches[1] * pow(1024, $exponent);
            break;
        }
        if (!is_numeric($value)) {
            throw new ComponentException(sprintf('"%s" is not a recognized file size.', $size));
        }
        return $value;
    }