<?php

/**
 * Verification Manager for Content Craft AI
 * 
 * Handles domain verification tokens and status
 */

if (!defined('ABSPATH')) {
  exit;
}

class ContentCraftAI_VerificationManager
{
  // Option name to store verification token
  const VERIFICATION_TOKEN_OPTION = 'content_craft_ai_verification_token';

  /**
   * Store a verification token in the database
   * 
   * @param string $token Verification token
   * @return bool Whether the option was updated
   */
  public static function store_token($token)
  {
    return update_option(self::VERIFICATION_TOKEN_OPTION, $token);
  }

  /**
   * Get the stored verification token
   * 
   * @return string|false Verification token or false if not set
   */
  public static function get_token()
  {
    return get_option(self::VERIFICATION_TOKEN_OPTION, false);
  }

  /**
   * Check if a token exists
   * 
   * @return bool Whether a token exists
   */
  public static function has_token()
  {
    return (bool) self::get_token();
  }

  /**
   * Delete the verification token
   * 
   * @return bool Whether the option was deleted
   */
  public static function delete_token()
  {
    return delete_option(self::VERIFICATION_TOKEN_OPTION);
  }

  /**
   * Get site domain for verification purposes
   * 
   * @return string The site domain
   */
  public static function get_site_domain()
  {
    $site_url = get_site_url();
    return wp_parse_url($site_url, PHP_URL_HOST);
  }
}
