Braintree\AddressGateway::_verifyGatewayResponse PHP Method

_verifyGatewayResponse() private method

creates a new Address object and encapsulates it inside a Result\Successful object, or encapsulates an Errors object inside a Result\Error alternatively, throws an Unexpected exception if the response is invalid
private _verifyGatewayResponse ( array $response ) : Braintree\Result\Successful | Error
$response array gateway response values
return Braintree\Result\Successful | Braintree\Result\Error
    private function _verifyGatewayResponse($response)
    {
        if (isset($response['address'])) {
            // return a populated instance of Address
            return new Result\Successful(Address::factory($response['address']));
        } else {
            if (isset($response['apiErrorResponse'])) {
                return new Result\Error($response['apiErrorResponse']);
            } else {
                throw new Exception\Unexpected("Expected address or apiErrorResponse");
            }
        }
    }