src/HttpFactory.php
public function createResponse(int $code = 200,
                                   string $reasonPhrase = null,
                                   array $headers = [],
                                   $body = null,
                                   $protocolVersion = '1.1'): ResponseInterface
    {
        $stream = null;
        if (!is_null($body)) {
            if (is_resource($body)) {
                $stream = $this->createStreamFromResource($body);
            }

            if (is_string($body)) {
                $stream = $this->createStream($body);
            }
        }

        $response = new Response($stream,
                                 $code,
                                 $headers,
                                 $reasonPhrase);

        // Protocol version ?
        if ($protocolVersion != $response->getProtocolVersion()) {
            $response = $response->withProtocolVersion($protocolVersion);
        }

        return $response;
    }
public function createResponse(int $code = 200,
                                   string $reasonPhrase = null,
                                   array $headers = [],
                                   $body = null,
                                   $protocolVersion = '1.1'): ResponseInterface
    {
        $stream = null;
        if (!is_null($body)) {
            if (is_resource($body)) {
                $stream = $this->createStreamFromResource($body);
            }

            if (is_string($body)) {
                $stream = $this->createStream($body);
            }
        }

        $response = new Response($stream,
                                 $code,
                                 $headers,
                                 $reasonPhrase);

        // Protocol version ?
        if ($protocolVersion != $response->getProtocolVersion()) {
            $response = $response->withProtocolVersion($protocolVersion);
        }

        return $response;
    }
Create a new response.

@param int                                  $code         The HTTP status code. Defaults to 200.
@param string                               $reasonPhrase The reason phrase to associate with the status code in
the generated response. If none is provided,
implementations MAY use the defaults as suggested in
the HTTP specification.
@param array                                $headers
@param resource|string|StreamInterface|null $body
@param string                               $protocolVersion

@return \Psr\Http\Message\ResponseInterface