Instantiate resource for response data if applicable

@param  array $result
@return mixed
507384
protected function response_data($result, $method, $url)
    {
        if (isset($result['$data'])) {
            if (is_array($result['$data'])) {
                return Resource::instance($result, $this);
            }
            return $result['$data'];
        }
        return null;
    }
1330191
protected function prepareResponse($result)
    {
        $this->checkForCurlErrors();

        $response = array();
        $response["data"] = $this->getSerializer()->deserialize($result);
        $response["status"] = $this->getStatusCode();


        if ($response['status'] >= 400 && $response['status'] < 500) {
            $statusCode = $response['status'];
            $exceptionText = "{$statusCode} Client Exception: {$result}";

            throw new ClientErrorException($exceptionText, $statusCode);
        } else if ($response['status'] >= 500) {
            $statusCode = $response['status'];
            $exceptionText = "{$statusCode} Server Exception: {$result}";

            throw new ServerErrorException($exceptionText, $statusCode);
        }

        return $response;
    }
1331717
public function getResponse($result)
    {
        $content = $result->getContent();

        if ($result->headers->get('content-type') == 'application/json'){
            $content = json_decode($result->getContent(),true);
        }

        return array(
          'type' => 'rpc',
          'tid' => $this->tid,
          'action' => $this->action,
          'method' => $this->method,
          'result' => $content
        );
    }
1281060
public static function instance($result, $client = null)
    {
        if ((array)$result['$data'] === $result['$data']
            && isset($result['$data']['results'])
            && isset($result['$data']['count'])) {
            return new Collection($result, $client);
        }
        
        return new Record($result, $client);
    }
765819
protected function filterResult(array $result) {
        foreach($result as $index => $user) {
            if (!is_object($user)) {
                throw new XjtuWebServiceException('Invalid response from web service server.');
            }
            foreach($user as $key => $val ) {
                if (!in_array($key, $this->fields) || in_array($key, $this->filter)) {
                    unset($user->$key);
                }
            }
            
            // $result[$index] = (array) $user;
        }
        return $result;
    }
809858
private function parseAccessToken(Result $result) {
        // If unexpected status code throw exception
        if ($result->getStatus() !== 200) {
            throw new OAuthException('Something went wrong requesting access token');
        }

        // Get the data form the result object
        $data = $result->getResult();

        // Store the data if available
        if (isset($data['access_token'])) {
            $this->setAccessToken($data['access_token']);
        }
        if (isset($data['refresh_token'])) {
            $this->setRefreshToken($data['refresh_token']);
        }
        if (isset($data['expire_time'])) {
            $this->setExpireTime(time() + $data['expire_time']);
        }
    }
401391
public function processResult(array $result) {
        list($result, $isRaw) = array_values($result);

        if(!$isRaw && is_string($result)) {
            return $this->createClone($result);
        }

        return $result;
    }
370088
public function build($result)
    {
        $modelResult = new ModelResult($this);
        $modelResult->models = $result;
        if (count($result) > 0) {
            $modelResult->model = $result[0];
        }
        if ($this->order !== '') {
            $modelResult->order($this->order);
        }
        return $modelResult;
    }
645337
private function createGetIteratorCallable(stdClass $result, Server $server)
    {
        // Inline results can be wrapped with an ArrayIterator
        if (isset($result->results) && is_array($result->results)) {
            $results = $result->results;

            return function() use ($results) {
                if (isset($this->options['typeMap'])) {
                    return new TypeMapArrayIterator($results, $this->options['typeMap']);
                }

                return new ArrayIterator($results);
            };
        }

        if (isset($result->result) && (is_string($result->result) || is_object($result->result))) {
            $options = isset($this->options['typeMap']) ? ['typeMap' => $this->options['typeMap']] : [];

            $find = is_string($result->result)
                ? new Find($this->databaseName, $result->result, [], $options)
                : new Find($result->result->db, $result->result->collection, [], $options);

            return function() use ($find, $server) {
                return $find->execute($server);
            };
        }

        throw new UnexpectedValueException('mapReduce command did not return inline results or an output collection');
    }
1089388
protected function prepareAccessTokenResponse(array $result)
    {
        $jwt = (new Parser())->parse($result['access_token']);
        $result['resource_owner_id'] = $jwt->getClaim('sub');
        $result['role'] = $jwt->getClaim('role');

        return $result;
    }
601501
public function addResult(Result $result): self
    {
        $handler = $result->getHandlerName();
        $this->results[$handler][] = $result;

        return $this;
    }
567530
protected function createModelFromDatabaseResult(array $result)
    {
        $model = $this->getEmptyModel();

        foreach ($result as $key => $value) {
            if ($key === $this->idProperty) {
                $model->setIdRaw($value);
            }

            $model->setPropertyRaw($key, StringUtil::deserialize($value));
        }

        return $model;
    }
92972
protected function processResponse(ResultSet $result = null)
    {
        $this->hits = array();
        if (is_null($result)) {
            return null;
        }
        $this->collectHits($result);
        $this->collectAggregations($result);
    }
207599
public function postProcess($result)
    {
        // determine whether there is anything to process
        if (    is_null($result)
            ||  is_a($result, Collection::class) && $result->isEmpty()
        ) {
            return $result;
        }

        // check if there is anything to do process it through
        if ($this->postProcessors->isEmpty()) return $result;


        // for each Model, instantiate and apply the processors
        if (is_a($result, Collection::class)) {

            $result->transform(function ($model) {
                return $this->applyPostProcessorsToModel($model);
            });

        } elseif (is_a($result, AbstractPaginator::class)) {
            // result is paginate() result
            // do not apply postprocessing for now (how would we even do it?)
            return $result;

        } else {
            // result is a model
            $result = $this->applyPostProcessorsToModel($result);
        }

        return $result;
    }
501181
protected function filterResult(Result $result)
    {
        $request = $result->getData('request') ?: array();
        if (!is_array($request)) {
            $request = $this->removeNS($request);
            $request = $this->serializer->decode($request, 'xml');

            if (isset($request['transactionRequest']['payment']['creditCard'])) {
                $request['transactionRequest']['payment']['creditCard'] = '[filtered]';
            }
            if (isset($request['transactionRequest']['payment']['trackData'])) {
                $request['transactionRequest']['payment']['trackData'] = '[filtered]';
            }

        }

        $result->setData('request', $request);

        return $result;
    }
721191
private static function convertResult($result)
    {
        if (!is_array($result)) {
            return self::convert($result);
        }

        $results = [];

        foreach ($result as $item) {
            $results[] = self::convert($item);
        }

        return $results;
    }
155786
public function create(Result $result)
    {
        $this->om->persist($result);
        $this->om->flush();

        return $result;
    }