*/ private array $data; /** * Load. */ public function __construct() { $stored = get_option( self::OPTION ); $this->data = is_array( $stored ) ? $stored : []; } /** * Read a value. * * @param string $key Key. * @param mixed $fallback Value when absent. */ public function get( string $key, mixed $fallback = null ): mixed { return $this->data[ $key ] ?? $fallback; } /** * Change values and persist. * * @param array $values Values to merge. */ public function update( array $values ): void { $this->data = array_merge( $this->data, $values ); update_option( self::OPTION, $this->data, false ); } /** * Current status, one of the constants above. */ public function status(): string { return (string) $this->get( 'status', self::OK ); } /** * Seconds to add to `time()` so signatures match the hub's clock. */ public function clockOffset(): int { return (int) $this->get( 'clock_offset', 0 ); } /** * Unix time before which nothing should be sent, or zero. */ public function waitUntil(): int { return (int) $this->get( 'wait_until', 0 ); } /** * Smallest gap between two sends the hub asked for, in seconds. */ public function minInterval(): int { return max( 0, (int) $this->get( 'min_interval', 0 ) ); } /** * Forget everything. */ public static function reset(): void { delete_option( self::OPTION ); } }