mirror of
https://gh.wpcy.net/https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2026-04-30 04:42:19 +08:00
24 lines
527 B
PHP
24 lines
527 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace WooCommerce\PayPalCommerce\FraudProtection;
|
|
|
|
/**
|
|
* A counter saving the current state into WP option.
|
|
*/
|
|
class PersistentCounter
|
|
{
|
|
protected string $option_id;
|
|
public function __construct(string $option_id)
|
|
{
|
|
$this->option_id = $option_id;
|
|
}
|
|
public function increment(): void
|
|
{
|
|
update_option($this->option_id, $this->current() + 1);
|
|
}
|
|
public function current(): int
|
|
{
|
|
return (int) get_option($this->option_id, 0);
|
|
}
|
|
}
|