private static function getStringFromBuffer($buffer, &$offset)
    {
        if (($length = self::getIntegerFromBuffer($buffer, $offset, ':')) < 0) {
            throw new DecodingException("Invalid string length: $length", $offset);
        }

        if ($length == 0) {
            return '';
        }

        $string = substr($buffer, $offset, $length);
        $offset += $length;

        return $string;
    }