protected function parseData($data)
    {
        $length = mb_strlen($data, '8bit');

        if ($this->cursor + $length > $this->getLength() + $this->headerLength) {
            $dataLength = $this->getLength()
                - $this->cursor
                + $this->headerLength;
        } else {
            $dataLength = $length;
        }

        $data     = mb_substr($data, 0, $dataLength, '8bit');
        $leftover = mb_substr($data, $length, $length - $dataLength, '8bit');

        $this->data .= $data;
        if ($this->isMasked()) {
            $this->unmaskedData .= $this->mask($data);
        } else {
            $this->unmaskedData .= $data;
        }
        $this->cursor += mb_strlen($data, '8bit');

        return $leftover;
    }