public function write($data)
    {
        $dataLength     = strlen($data);
        $start          = substr($this->buffer, 0, $this->position);
        $end            = substr($this->buffer, $this->position + $dataLength);
        $this->buffer   = $start.$data.$end;
        $this->length   = strlen($this->buffer);
        $this->position += $dataLength;
        return $dataLength;
    }