protected function getLength($limit)
    {
        $size = strlen($this->data);
        if ($limit <= 0) {
            $limit += $size;
        }

        if ($limit > $size) {
            return null;
        }

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