Returns a Response object.

@param mixed $result

@return \GuzzleHttp\Psr7\Response|string
431361
private function returnResponse($result): Response
    {
        if ($result instanceof Response) {
            return $result;
        }

        if (is_array($result)) {
            $result = json_encode($result);
        }

        return new Response(200, [], $result);
    }
182804
public function prepareResponse($result)
    {
        $response = ['header' => null, 'content' => null];
        $d = "\r\n\r\n"; // Headers and content delimiter

        if (is_string($result) && strpos($result, $d) !== false) {
            list($header, $content) = explode($d, $result, 2);
            if (stripos($header, '100 Continue') !== false && strpos($content, $d) !== false) {
                list($header, $content) = explode($d, $content, 2);
            }
            $response['header'] = $header;
            $response['content'] = htmlentities($content);
        }

        return $response;
    }
595415
protected function getResponse( $response ) {
		if ( is_string( $response ) ) {
			return Response::output( $response );
		}

		if ( is_array( $response ) ) {
			return Response::json( $response );
		}

		if ( $response instanceof ResponsableInterface ) {
			return $response->toResponse();
		}

		return $response;
	}
212457
protected function buildResponse($result, ResponseInterface $response, RequestInterface $request)
    {

        $responseBuilder   = $this->container->getResponseBuilder();
        $responseFormatter = $this->container->getResponseFormatter();

        if (!is_callable($responseBuilder)) {
            throw new ResponseBuilderException('ResponseBuilder must be callable or implements ResponseBuilderInterface');
        }
        if (!is_callable($responseFormatter)) {
            throw new ResponseFormatterException('ResponseFormatter must be callable or implements ResponseFormatterInterface');
        }
        if (method_exists($responseBuilder, 'setRequest')) {
            $responseBuilder->setRequest($request);
        }

        $result = $responseBuilder($result);

        return $responseFormatter($response, $result);
    }
1241759
public function serialize($result)
    {
        try {
            // array is serialized as an object {"0":{...},"1":{...},...} when data contains an empty objects
            // we serialize each item because we can assume this bug affects only root array element
            if (is_array($result) && array_keys($result) === range(0, count($result) - 1)) {
                $result = array_map(
                    function ($item) {
                        return $this->serializeContent($item);
                    },
                    $result
                );

                return '['.implode(',', array_filter($result)).']';
            }

            return $this->serializeContent($result);
        } catch (\Exception $e) {
            throw new SerializationException($e);
        }
    }
171687
private function processResult(array $result)
    {
        $this->checkResponseStatus($result['http_code']);

        // Get decoded response data
        $responseArr = json_decode($result['response'], true);

        $this->checkJsonError();

        return $responseArr;
    }
1131342
public function fetchResult($result)
    {
        $fetchMode = $this->fetchMode;
        switch ($fetchMode) {
            case PDO::FETCH_ASSOC:
                return $result->result_array();
            case PDO::FETCH_OBJ:
                return $result->result();
        }

        throw new \BadMethodCallException("Unsupported fetch mode '$fetchMode'.");
    }
671581
public function setControllerResult($result)
    {
        $event = $this->getSymfonyEvent();
        if ($event instanceof GetResponseForControllerResultEvent) {
            $event->setControllerResult($result);
        }

        return $this;
    }
1194021
public function parserResult($result)
    {
        if ($this->presenter instanceof PresenterInterface) {
            if ($result instanceof Collection || $result instanceof LengthAwarePaginator) {
                $result->each(function ($model) {
                    if ($model instanceof Presentable) {
                        $model->setPresenter($this->presenter);
                    }

                    return $model;
                });
            } elseif ($result instanceof Presentable) {
                $result = $result->setPresenter($this->presenter);
            }

            if (!$this->skipPresenter) {
                return $this->presenter->present($result);
            }
        }

        return $result;
    }
298754
final public static function adapter($result)
    {
        if (is_array($result)) {
            $arr = [];
            foreach ($result as $key => $value) {
                $arr[$key] = self::makeObject($value);
            }
            return $arr;
        }

        return self::makeObject($result);
    }
933973
public function validAuthenticationResponse($request, $result)
    {
        if (Str::startsWith($request->channel_name, 'private')) {
            return $this->decodePusherResponse(
                $this->pusher->socket_auth($request->channel_name, $request->socket_id)
            );
        }

        return $this->decodePusherResponse(
            $this->pusher->presence_auth(
                $request->channel_name, $request->socket_id, $request->user()->getAuthIdentifier(), $result)
        );
    }
1265379
protected function show($result)
    {
        $callback = Yii::$app->request->get('callback', null);

        if ($callback && is_string($callback)) {
            Yii::$app->response->format = yii\web\Response::FORMAT_JSONP;
            return [
                'callback' => $callback,
                'data' => $result
            ];
        }

        Yii::$app->response->format = yii\web\Response::FORMAT_JSON;
        return $result;
    }
1215960
public function encodeResult($result)
	{
		$string = $this->encoder->encodeResult($result);

		return $this->encrypt($string);
	}
478198
protected function respond($response)
    {
        if ($response === null) {
            return $this->mapResponse(true, []);
        }

        if (!empty($response) && !isset($response[0])) {
            $success = null === Arr::get($response, 'error_code');

            return $this->mapResponse($success, $response);
        }

        $responses = [];

        foreach ($response as $responseItem) {
            $success = null === Arr::get($responseItem, 'error_code');

            $responses[] = $this->mapResponse($success, $responseItem);
        }

        return $responses;
    }
370878
public function sendResponse($result)
    {
        if (!($this->framework->getRequest() instanceof WebRequest)) {
            return;
        }
        
        return $this->restHelper->sendResponse($this->framework->getRequest(), $this->framework->getResponse(), $result);
    }
521807
public function onResult(\pq\Result $result = null) {
		if ($result && $result->status != \pq\Result::TUPLES_OK) {
			return $result;
		}
		
		$rowset = $this->getRowsetPrototype();
		if (is_callable($rowset)) {
			return $rowset($result);
		} elseif ($rowset) {
			return new $rowset($this, $result);
		}
		
		return $result;
	}
1160717
public function responseIsSuccessfullyWithContainScalarResult($result)
    {
        Assertions::assertEquals(200, $this->response->getStatusCode(), sprintf(
            'Response with error "%s"',
            $this->response->getBody()
        ));

        Assertions::assertTrue(is_null($this->response->getRpcErrorCode()), sprintf(
            'Response with error "%s"',
            $this->response->getBody()
        ));

        Assertions::assertEquals($result, $this->response->getRpcResult(), sprintf(
            'Result must be a contain "%s"',
            $result
        ));
    }