public function read($length)
    {
        if (!$this->isReadable()) {
            throw new \RuntimeException('Could not read the stream because it is not readable');
        }

        $string = fread($this->stream, (int)$length);
        if ($string === false) {
            throw new \RuntimeException('Could not read the stream because of an error on fread()');
        }

        return $string;
    }