<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

class W2PShopSaverUtil {
	public static function save_text_field(array &$settings, string $field): void{
		// This should only be run after a nonce check is done by the parent function, this is just a helper.
		// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce verification is handled by the calling function
		if (isset($_REQUEST[$field])) {
			// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce verification is handled by the calling function
			$settings[$field] = sanitize_text_field(wp_unslash($_REQUEST[$field]));
		}
	}

	public static function save_default_false(array &$settings, string $field): void{
		// This should only be run after a nonce check is done by the parent function, this is just a helper.
		// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce verification is handled by the calling function
		if (isset($_REQUEST[$field])) {
			// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce verification is handled by the calling function
			$settings[$field] = sanitize_text_field(wp_unslash($_REQUEST[$field]));
		} else {
			$settings[$field] = false;
		}
	}

}