mirror of
https://gh.wpcy.net/https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2026-05-02 05:02:40 +08:00
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Helper class to determine if credit messaging should be displayed.
|
|
*
|
|
* @package WooCommerce\PayPalCommerce\Button\Helper
|
|
*/
|
|
declare (strict_types=1);
|
|
namespace WooCommerce\PayPalCommerce\Button\Helper;
|
|
|
|
/**
|
|
* Class MessagesApply
|
|
*/
|
|
class MessagesApply
|
|
{
|
|
/**
|
|
* In which countries credit messaging is available.
|
|
*
|
|
* @var string[]
|
|
*/
|
|
private $allowed_countries;
|
|
/**
|
|
* 2-letter country code of the shop.
|
|
*
|
|
* @var string
|
|
*/
|
|
private $country;
|
|
/**
|
|
* MessagesApply constructor.
|
|
*
|
|
* @param string[] $allowed_countries In which countries credit messaging is available.
|
|
* @param string $country 2-letter country code of the shop.
|
|
*/
|
|
public function __construct(array $allowed_countries, string $country)
|
|
{
|
|
$this->allowed_countries = $allowed_countries;
|
|
$this->country = $country;
|
|
}
|
|
/**
|
|
* Determines whether a credit messaging is enabled for the shops location country.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function for_country(): bool
|
|
{
|
|
return in_array($this->country, $this->allowed_countries, \true);
|
|
}
|
|
}
|