src/Charcoal/Property/FileProperty.php
protected function parseIniSize($size)
    {
        if (is_numeric($size)) {
            return $size;
        }

        if (!is_string($size)) {
            throw new InvalidArgumentException(
                'Size must be an integer (in bytes, e.g.: 1024) or a string (e.g.: 1M).'
            );
        }

        $quant = 'bkmgtpezy';
        $unit = preg_replace('/[^'.$quant.']/i', '', $size);
        $size = preg_replace('/[^0-9\.]/', '', $size);

        if ($unit) {
            $size = ($size * pow(1024, stripos($quant, $unit[0])));
        }

        return round($size);
    }
protected function parseIniSize($size)
    {
        if (is_numeric($size)) {
            return $size;
        }

        if (!is_string($size)) {
            throw new InvalidArgumentException(
                'Size must be an integer (in bytes, e.g.: 1024) or a string (e.g.: 1M).'
            );
        }

        $quant = 'bkmgtpezy';
        $unit = preg_replace('/[^'.$quant.']/i', '', $size);
        $size = preg_replace('/[^0-9\.]/', '', $size);

        if ($unit) {
            $size = ($size * pow(1024, stripos($quant, $unit[0])));
        }

        return round($size);
    }
protected function parseIniSize ( $ size ) { if ( is_numeric ( $ size ) ) { return $ size ; } if ( ! is_string ( $ size ) ) { throw new InvalidArgumentException ( 'Size must be an integer (in bytes, e.g.: 1024) or a string (e.g.: 1M).' ) ; } $ quant = 'bkmgtpezy' ; $ unit = preg_replace ( '/[^' . $ quant . ']/i' , '' , $ size ) ; $ size = preg_replace ( '/[^0-9\.]/' , '' , $ size ) ; if ( $ unit ) { $ size = ( $ size * pow ( 1024 , stripos ( $ quant , $ unit [ 0 ] ) ) ) ; } return round ( $ size ) ; }
Converts a php.ini notation for size to an integer.

@param  mixed $size A php.ini notation for size.
@throws InvalidArgumentException If the given parameter is invalid.
@return integer Returns the size in bytes.
Converts a php . ini notation for size to an integer .