MatthiasMullie\Scrapbook\Adapters\MemoryStore::shorthandToBytes PHP Метод

shorthandToBytes() защищенный Метод

Understands shorthand byte values (as used in e.g. memory_limit ini setting) and converts them into bytes.
См. также: http://php.net/manual/en/faq.using.php#faq.using.shorthandbytes
protected shorthandToBytes ( string | integer $shorthand ) : integer
$shorthand string | integer Amount of bytes (int) or shorthand value (e.g. 512M)
Результат integer
    protected function shorthandToBytes($shorthand)
    {
        if (is_numeric($shorthand)) {
            // make sure that when float(1.234E17) is passed in, it doesn't get
            // cast to string('1.234E17'), then to int(1)
            return $shorthand;
        }
        $units = array('B' => 1024, 'M' => pow(1024, 2), 'G' => pow(1024, 3));
        return (int) preg_replace_callback('/^([0-9]+)(' . implode(array_keys($units), '|') . ')$/', function ($match) use($units) {
            return $match[1] * $units[$match[2]];
        }, $shorthand);
    }