protected function getDelimiter($limit)
    {
        if ($limit === '') {
            throw new \InvalidArgumentException();
        }

        $pos = strpos($this->data, $limit);
        if ($pos === false) {
            return null;
        }

        $pos += strlen($limit);
        $res = substr($this->data, 0, $pos);
        $this->data = (string) substr($this->data, $pos);
        return $res;
    }