<?php
/**
 * Form Session Data Class
 *
 * This class manages session data for form submissions, including email and phone
 * verification status, submission status, and form identification.
 *
 * @package miniorange-sms-order-notification-otp-verification/objects
 */

namespace WCSMSOTP\Objects;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

if ( ! class_exists( 'FormSessionData' ) ) {
	/**
	 * Form Session Data Class
	 *
	 * This class manages session data for form submissions, including email and phone
	 * verification status, submission status, and form identification.
	 */
	class FormSessionData {
		/**
		 * Whether the session data has been initialized.
		 *
		 * @var bool
		 */
		private $is_initialized = false;

		/**
		 * Email submission status.
		 *
		 * @var mixed
		 */
		private $email_submitted;

		/**
		 * Phone submission status.
		 *
		 * @var mixed
		 */
		private $phone_submitted;

		/**
		 * Email verification status.
		 *
		 * @var mixed
		 */
		private $email_verified;

		/**
		 * Phone verification status.
		 *
		 * @var mixed
		 */
		private $phone_verified;

		/**
		 * Email verification status value.
		 *
		 * @var mixed
		 */
		private $email_verification_status;

		/**
		 * Phone verification status value.
		 *
		 * @var mixed
		 */
		private $phone_verification_status;

		/**
		 * Form or field ID.
		 *
		 * @var mixed
		 */
		private $field_or_form_id;

		/**
		 * User submitted data.
		 *
		 * @var mixed
		 */
		private $user_submitted;


		/**
		 * Constructor.
		 *
		 * Initializes a new instance of the FormSessionData class.
		 */
		public function __construct() {}

		/**
		 * Initialize the session data.
		 *
		 * @return $this Returns the current instance for method chaining.
		 */
		public function init() {
			$this->is_initialized = true;
			return $this;
		}

		/**
		 * Get whether the session data has been initialized.
		 *
		 * @return bool Whether the session data is initialized.
		 */
		public function get_is_initialized() {
			return $this->is_initialized;
		}

		/**
		 * Get the email submission status.
		 *
		 * @return mixed The email submission status.
		 */
		public function get_email_submitted() {
			return $this->email_submitted;
		}

		/**
		 * Set the email submission status.
		 *
		 * @param mixed $email_submitted Email submission status.
		 */
		public function set_email_submitted( $email_submitted ) {
			if ( is_bool( $email_submitted ) || is_string( $email_submitted ) ) {
				$this->email_submitted = is_string( $email_submitted ) ? sanitize_text_field( $email_submitted ) : $email_submitted;
			}
		}

		/**
		 * Get the phone submission status.
		 *
		 * @return mixed The phone submission status.
		 */
		public function get_phone_submitted() {
			return $this->phone_submitted;
		}

		/**
		 * Set the phone submission status.
		 *
		 * @param mixed $phone_submitted Phone submission status.
		 */
		public function set_phone_submitted( $phone_submitted ) {
			if ( is_bool( $phone_submitted ) || is_string( $phone_submitted ) ) {
				$this->phone_submitted = is_string( $phone_submitted ) ? sanitize_text_field( $phone_submitted ) : $phone_submitted;
			}
		}

		/**
		 * Get the email verification status.
		 *
		 * @return mixed The email verification status.
		 */
		public function get_email_verified() {
			return $this->email_verified;
		}

		/**
		 * Set the email verification status.
		 *
		 * @param mixed $email_verified Email verification status.
		 */
		public function set_email_verified( $email_verified ) {
			if ( is_bool( $email_verified ) || is_string( $email_verified ) ) {
				$this->email_verified = is_string( $email_verified ) ? sanitize_text_field( $email_verified ) : $email_verified;
			}
		}

		/**
		 * Get the phone verification status.
		 *
		 * @return mixed The phone verification status.
		 */
		public function get_phone_verified() {
			return $this->phone_verified;
		}

		/**
		 * Set the phone verification status.
		 *
		 * @param mixed $phone_verified Phone verification status.
		 */
		public function set_phone_verified( $phone_verified ) {
			if ( is_bool( $phone_verified ) || is_string( $phone_verified ) ) {
				$this->phone_verified = is_string( $phone_verified ) ? sanitize_text_field( $phone_verified ) : $phone_verified;
			}
		}

		/**
		 * Get the email verification status value.
		 *
		 * @return mixed The email verification status value.
		 */
		public function get_email_verification_status() {
			return $this->email_verification_status;
		}

		/**
		 * Set the email verification status value.
		 *
		 * @param mixed $email_verification_status Email verification status value.
		 */
		public function set_email_verification_status( $email_verification_status ) {
			if ( is_bool( $email_verification_status ) || is_string( $email_verification_status ) ) {
				$this->email_verification_status = is_string( $email_verification_status ) ? sanitize_text_field( $email_verification_status ) : $email_verification_status;
			}
		}

		/**
		 * Get the phone verification status value.
		 *
		 * @return mixed The phone verification status value.
		 */
		public function get_phone_verification_status() {
			return $this->phone_verification_status;
		}

		/**
		 * Set the phone verification status value.
		 *
		 * @param mixed $phone_verification_status Phone verification status value.
		 */
		public function set_phone_verification_status( $phone_verification_status ) {
			if ( is_bool( $phone_verification_status ) || is_string( $phone_verification_status ) ) {
				$this->phone_verification_status = is_string( $phone_verification_status ) ? sanitize_text_field( $phone_verification_status ) : $phone_verification_status;
			}
		}

		/**
		 * Get the form or field ID.
		 *
		 * @return mixed The form or field ID.
		 */
		public function get_field_or_form_id() {
			return $this->field_or_form_id;
		}

		/**
		 * Set the form or field ID.
		 *
		 * @param mixed $field_or_form_id Form or field ID.
		 */
		public function set_field_or_form_id( $field_or_form_id ) {
			if ( is_string( $field_or_form_id ) || is_numeric( $field_or_form_id ) ) {
				$this->field_or_form_id = is_string( $field_or_form_id ) ? sanitize_text_field( $field_or_form_id ) : $field_or_form_id;
			}
		}

		/**
		 * Get the user submitted data.
		 *
		 * @return mixed The user submitted data.
		 */
		public function get_user_submitted() {
			return $this->user_submitted;
		}

		/**
		 * Set the user submitted data.
		 *
		 * @param mixed $user_submitted User submitted data.
		 */
		public function set_user_submitted( $user_submitted ) {
			if ( is_string( $user_submitted ) || is_array( $user_submitted ) || is_object( $user_submitted ) ) {
				if ( is_string( $user_submitted ) ) {
					$this->user_submitted = sanitize_text_field( $user_submitted );
				} else {
					$this->user_submitted = $user_submitted;
				}
			}
		}
	}
}
