src/CoreHandler.php
private function wrapResponse(Response $response, $result = null, string $output = ''): Response
    {
        if ($result instanceof Response) {
            if (!empty($output) && $result->getBody()->isWritable()) {
                $result->getBody()->write($output);
            }

            return $result;
        }

        if (is_array($result) || $result instanceof \JsonSerializable) {
            $response = $this->writeJson($response, $result);
        } else {
            $response->getBody()->write($result);
        }

        //Always glue buffered output
        $response->getBody()->write($output);

        return $response;
    }
private function wrapResponse(Response $response, $result = null, string $output = ''): Response
    {
        if ($result instanceof Response) {
            if (!empty($output) && $result->getBody()->isWritable()) {
                $result->getBody()->write($output);
            }

            return $result;
        }

        if (is_array($result) || $result instanceof \JsonSerializable) {
            $response = $this->writeJson($response, $result);
        } else {
            $response->getBody()->write($result);
        }

        //Always glue buffered output
        $response->getBody()->write($output);

        return $response;
    }
private function wrapResponse ( Response $ response , $ result = null , string $ output = '' ) : Response { if ( $ result instanceof Response ) { if ( ! empty ( $ output ) && $ result -> getBody ( ) -> isWritable ( ) ) { $ result -> getBody ( ) -> write ( $ output ) ; } return $ result ; } if ( is_array ( $ result ) || $ result instanceof \ JsonSerializable ) { $ response = $ this -> writeJson ( $ response , $ result ) ; } else { $ response -> getBody ( ) -> write ( $ result ) ; } //Always glue buffered output $ response -> getBody ( ) -> write ( $ output ) ; return $ response ; }
Convert endpoint result into valid response.

@param Response $response Initial pipeline response.
@param mixed    $result   Generated endpoint output.
@param string   $output   Buffer output.
@return Response
Convert endpoint result into valid response .