public function getContents(): string
{ if (!
isset($this->stream
)) { throw new \
RuntimeException('Stream is detached'
);
} if (!
$this->readable
) { throw new \
RuntimeException('Cannot read from non-readable stream'
);
} return Utils::
tryGetContents($this->stream
);
} public function close(): void
{ if (isset($this->stream
)) { if (is_resource($this->stream
)) { fclose($this->stream
);
} $this->
detach();
} }