public function close()
    {
        if ($this->isOpen() === false) {
            $msg = "Cannot call close() a closed stream.";
            throw new MemoryStreamException($msg, $this, MemoryStreamException::NOT_OPEN);
        }

        $this->setOpen(false);
    }