src/Valkyrja/HttpMessage/NativeStream.php
public function write(string $string): int
    {
        // If there is no stream
        if (null === $this->stream) {
            // Throw a new runtime exception
            throw new RuntimeException(
                'No resource available; cannot write'
            );
        }

        // If the stream isn't seekable
        if (! $this->isSeekable()) {
            // Throw a new runtime exception
            throw new RuntimeException(
                'Stream is not writable'
            );
        }

        // Attempt to write to the stream
        $result = fwrite($this->stream, $string);

        // If the write was not successful
        if (false === $result) {
            // Throw a runtime exception
            throw new RuntimeException(
                'Error writing to stream'
            );
        }

        return $result;
    }
public function write(string $string): int
    {
        // If there is no stream
        if (null === $this->stream) {
            // Throw a new runtime exception
            throw new RuntimeException(
                'No resource available; cannot write'
            );
        }

        // If the stream isn't seekable
        if (! $this->isSeekable()) {
            // Throw a new runtime exception
            throw new RuntimeException(
                'Stream is not writable'
            );
        }

        // Attempt to write to the stream
        $result = fwrite($this->stream, $string);

        // If the write was not successful
        if (false === $result) {
            // Throw a runtime exception
            throw new RuntimeException(
                'Error writing to stream'
            );
        }

        return $result;
    }
Write data to the stream.

@param string $string The string that is to be written.

@throws \RuntimeException on failure.

@return int Returns the number of bytes written to the stream.