HEX
Server: Apache
System: Linux ecngx285.inmotionhosting.com 4.18.0-553.79.1.lve.el8.x86_64 #1 SMP Wed Oct 15 17:59:35 UTC 2025 x86_64
User: zeusxp5 (3862)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /home/zeusxp5/tour.kamille.us/wp-content/plugins/surecart/app/src/Models/ApiToken.php
<?php

namespace SureCart\Models;

use SureCart\Support\Encryption;

/**
 * The API token model.
 */
class ApiToken {

	/**
	 * The option key.
	 *
	 * @var string
	 */
	protected $key = 'sc_api_token';

	/**
	 * Prevent php warnings.
	 */
	final public function __construct() {}

	/**
	 * Clear the API token.
	 *
	 * @return bool True if the value was updated, false otherwise.
	 */
	protected function clear() {
		return delete_option( $this->key );
	}

	/**
	 * Save and encrypt the API token.
	 *
	 * @param string $value The API token.
	 * @return bool True if the value was updated, false otherwise.
	 */
	protected function save( $value ) {
		$saved = update_option( $this->key, Encryption::encrypt( $value ) );
		\SureCart::requests()->setToken( $value );
		return $saved;
	}

	/**
	 * Get and decrypt the API token
	 *
	 * @return string The decoded API token.
	 */
	protected function get() {
		if ( defined( 'SURECART_API_TOKEN' ) ) {
			return SURECART_API_TOKEN;
		}
		return Encryption::decrypt( get_option( $this->key, '' ) );
	}

	/**
	 * Forward call to method
	 *
	 * @param string $method Method to call.
	 * @param mixed  $params Method params.
	 */
	public function __call( $method, $params ) {
		return call_user_func_array( [ $this, $method ], $params );
	}

	/**
	 * Static Facade Accessor
	 *
	 * @param string $method Method to call.
	 * @param mixed  $params Method params.
	 *
	 * @return mixed
	 */
	public static function __callStatic( $method, $params ) {
		return call_user_func_array( [ new static(), $method ], $params );
	}
}