@param Result $result
@return AuthenticationResult

@throws \Exception
334130
protected function marshalZendResult(Result $result): AuthenticationResult
    {
        $code = Utils::$authResultCodeMap[$result->getCode()];
        //we'll give the user only general error info, to prevent user enumeration attacks
        $message = Utils::$authCodeToMessage[$code];

        $identity = null;
        if ($result->isValid()) {
            $identity = $result->getIdentity();
            //try to convert to array if not already...
            $identity = (array)$identity;
            if (empty($identity)) {
                throw new RuntimeException("Missing identity object or cannot be converted to array");
            }

            $identity = $this->hydrateIdentity($identity);
        }

        return new AuthenticationResult($code, $message, $identity);
    }
628648
protected function hydrateEntity($result)
    {
        $client = new ClientEntity($this->getServer());
        $client->hydrate([
            'id' => $result->id,
            'name' => $result->name,
            'secret' => $result->secret,
            'redirectUri' => (isset($result->redirect_uri) ? $result->redirect_uri : null),
        ]);

        return $client;
    }
595239
public static function keyPair(array $result): array
    {
        $firstRow = current($result);
        if (empty($firstRow)) {
            return $result;
        }

        list($keyName, $valueName) = array_keys($firstRow);

        return array_combine(
            array_column($result, $keyName),
            array_column($result, $valueName)
        );
    }
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;
	}
748213
protected function _makeResult(array $result) {
        return Result::make($result, $this->getClient())->setModelClass($this->_fullModelClass());
    }
450041
public function authenticate()
    {
        /* @var $user \Grid\User\Model\User\Structure */
        $user = $this->getModel()
                     ->findByEmail( $this->email );

        if ( empty( $user ) )
        {
            return new Result( Result::FAILURE_IDENTITY_NOT_FOUND, null );
        }

        if ( ! $user->isActive() ||
             ! $user->verifyPassword( $this->password, true ) )
        {
            return new Result( Result::FAILURE_CREDENTIAL_INVALID, null );
        }

        return new Result( Result::SUCCESS, $user );
    }
739307
protected function _checkResult($result) {
        $rvalue = true;
        foreach ($result as $socketName => $value) {
            if ($value !== true) {
                Mage::helper('turpentine/debug')->logWarn(
                    'Error in Varnish action result for server [%s]: %s',
                    $socketName, $value );
                $rvalue = false;
            }
        }
        return $rvalue;
    }
569193
private function castResult($result)
    {
        try {
            $result = $this->typeAdapter->toArray($result);
        } catch (TypeCastException $exception) {
            return $result;
        }

        return $result;
    }
370878
public function sendResponse($result)
    {
        if (!($this->framework->getRequest() instanceof WebRequest)) {
            return;
        }
        
        return $this->restHelper->sendResponse($this->framework->getRequest(), $this->framework->getResponse(), $result);
    }
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;
    }
862424
public static function buildMessage(ResultException $result)
    {
        $translateKey = self::TRANSLATE_KEY_PREFIX . $result->globalCode;
        $message = self::translate($translateKey);

        return empty($message) ? $result->getAlias() : $message;
    }
529833
protected function throwExceptionOnClientCallFailure($result)
    {
        if ($result !== false) {
            return;
        }

        throw new OperationFailed(
            $this->client->getResultMessage(),
            $this->client->getResultCode()
        );
    }
1068729
public function authenticate()
    {
        if (empty($this->authResult)) {
            if ($this->hasIdentity()) {
                $this->clearIdentity();
            }

            return new Result(
                Result::FAILURE_UNCATEGORIZED,
                null,
                ['no result set']
            );
        }

        if ($this->hasIdentity()) {
            $this->clearIdentity();
        }

        if ($this->authResult->isValid()) {
            $this->getStorage()->write($this->authResult->getIdentity());
        }

        $result = $this->authResult;
        $this->authResult = null;

        return $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)
        );
    }
842746
protected function _makeResult(array $result) {
        return Result::make($result, $this->getClient())->setModelClass($this->_fullModelClassNamePattern());
    }
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']);
        }
    }
1025879
protected function makeObject(IResult $result) {

        // TODO: Prefer to return existing instance from IdentityMap

        $row = $result->fetchRow(ARRAY_ASSOC);
        if ($row === null)
            return null;
        return PersistableObject::populateNew($this->entityClass, $row);
    }