woocommerce-paypal-payments/modules/ppcp-vaulting/src/PaymentTokenHelper.php

36 lines
675 B
PHP
Raw Normal View History

<?php
/**
* Payment Tokens helper methods.
*
* @package WooCommerce\PayPalCommerce\Vaulting
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Vaulting;
2023-09-07 10:08:18 +02:00
use WC_Payment_Token;
/**
* Class PaymentTokenHelper
*/
class PaymentTokenHelper {
/**
2023-09-07 10:08:18 +02:00
* Checks if given token exist as WC Payment Token.
*
2023-09-07 10:08:18 +02:00
* @param WC_Payment_Token[] $wc_tokens WC Payment Tokens.
* @param string $token_id Payment Token ID.
* @return bool
*/
public function token_exist( array $wc_tokens, string $token_id ): bool {
foreach ( $wc_tokens as $wc_token ) {
if ( $wc_token->get_token() === $token_id ) {
return true;
}
}
return false;
}
}