PayPal\Validation\ArgumentValidator::validate PHP Метод

validate() публичный статический Метод

Helper method for validating an argument that will be used by this API in any requests.
public static validate ( $argument, $argumentName = null ) : boolean
$argument mixed The object to be validated
$argumentName string|null The name of the argument. This will be placed in the exception message for easy reference
Результат boolean
    public static function validate($argument, $argumentName = null)
    {
        if ($argument === null) {
            // Error if Object Null
            throw new \InvalidArgumentException("{$argumentName} cannot be null");
        } elseif (gettype($argument) == 'string' && trim($argument) == '') {
            // Error if String Empty
            throw new \InvalidArgumentException("{$argumentName} string cannot be empty");
        }
        return true;
    }

Usage Example

Пример #1
0
 /**
  * Retrieves the list of events-types subscribed by the given Webhook.
  *
  * @param string $webhookId
  * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
  * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
  * @return WebhookEventTypeList
  */
 public static function subscribedEventTypes($webhookId, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($webhookId, 'webhookId');
     $payLoad = "";
     $json = self::executeCall("/v1/notifications/webhooks/{$webhookId}/event-types", "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new WebhookEventTypeList();
     $ret->fromJson($json);
     return $ret;
 }
All Usage Examples Of PayPal\Validation\ArgumentValidator::validate
ArgumentValidator