<?php
/**
 * PostGate Bridge Configuration Class
 *
 * This file contains the bridge server configuration management class
 * that provides access to bridge server settings and credentials.
 *
 * @package PostGate
 * @subpackage BridgeIntegration
 * @since 1.0.0
 * @author QodeSphere
 * @license GPL-2.0+
 */

defined( 'ABSPATH' ) || exit;

/**
 * PostGate Bridge Configuration Class
 *
 * Manages configuration settings for the PostGate Bridge server.
 * Provides access to bridge URL and shared secret for secure
 * communication between the WordPress plugin and bridge server.
 *
 * The bridge server handles OAuth authentication and secure
 * credential management for Stripe integration.
 *
 * @since 1.0.0
 */
class PostGate_Bridge_Config {

	/**
	 * Get the bridge server URL.
	 *
	 * Returns the configured bridge server URL with trailing slash removed.
	 * Defaults to the official PostGate bridge server if not configured.
	 *
	 * @since 1.0.0
	 * @return string The bridge server URL without trailing slash.
	 */
	public static function url(): string {
		$u = get_option( 'postgate_bridge_url', 'https://postgate-bridge.qodesphere.com' );
		return untrailingslashit( $u );
	}

	/**
	 * Get the shared secret for bridge communication.
	 *
	 * Returns the shared secret used for HMAC signing of requests
	 * to the bridge server. Required for authenticated communication.
	 *
	 * @since 1.0.0
	 * @return string The shared secret for bridge authentication.
	 */
	public static function shared_secret(): string {
		return (string) get_option( 'postgate_bridge_shared_secret', '' );
	}
}
