<?php

use PWH_DCFH\App\Helpers\PWH_DCFH_Helpers;
use PWH_DCFH\App\Controllers\PWH_DCFH_DB;
use PWH_DCFH\App\Admin\Handlers\PWH_DCFH_User_Handler;
use PWH_DCFH\App\Admin\Handlers\PWH_DCFH_Post_Meta_Handler;
use PWH_DCFH\App\Admin\Handlers\PWH_DCFH_Email_Template_Handler;
use PWH_DCFH\App\Admin\Logger\PWH_DCFH_Logger;
use PWH_DCFH\App\Frontend\Controllers\PWH_DCFH_Email_Merge_Tags_Handler;
use PWH_DCFH\App\Helpers\PWH_DCFH_Module_Helpers;
use PWH_DCFH\App\Helpers\PWH_DCFH_File_Helpers;
use PWH_DCFH\App\Admin\Controllers\PWH_DCFH_Admin_Notice;
use PWH_DCFH\App\Helpers\PWH_DCFH_WP_Helpers;

// Auto Load Vendor
// phpcs:disable
require_once __DIR__.'/vendor/autoload.php';
// phpcs:enable
/**
 * Helper function to get the instance of PWH_DCFH_Helpers class.
 * This function returns the instance of PWH_DCFH_Helpers class.
 * If the class doesn't
 * exist or if the instance cannot be created, it returns null.
 * @return PWH_DCFH_Helpers|null The instance of PWH_DCFH_Helpers class, or null if the class doesn't exist or the instance cannot be created.
 */
if (!function_exists('pwh_dcfh_helpers')):
    function pwh_dcfh_helpers()
    {
        return PWH_DCFH_Helpers::instance();
    }
endif;
/**
 * Returns an instance of PWH_DCFH_WP_Helpers.
 * This function is used to get an instance of the PWH_DCFH_WP_Helpers class,
 * ensuring that only one instance is created per request.
 * @return PWH_DCFH_WP_Helpers An instance of PWH_DCFH_WP_Helpers class.
 */
if (!function_exists('pwh_dcfh_wp_helpers')):
    function pwh_dcfh_wp_helpers()
    {
        return PWH_DCFH_WP_Helpers::instance();
    }
endif;
/**
 * Retrieves an instance of PWH_DCFH_Module_Helpers.
 * If the function doesn't already exist, it is defined and returns an instance
 * of the PWH_DCFH_Module_Helpers class.
 * @return PWH_DCFH_Module_Helpers An instance of the PWH_DCFH_Module_Helpers class.
 */
if (!function_exists('pwh_dcfh_module_helpers')):
    function pwh_dcfh_module_helpers()
    {
        return PWH_DCFH_Module_Helpers::instance();
    }
endif;
/**
 * Check if the function 'pwh_dcfh_admin_notice' does not already exist, then define it.
 * This function returns an instance of the PWH_DCFH_Admin_Notice class.
 * @return PWH_DCFH_Admin_Notice The instance of the PWH_DCFH_Admin_Notice class.
 */
if (!function_exists('pwh_dcfh_admin_notice')):
    function pwh_dcfh_admin_notice()
    {
        return PWH_DCFH_Admin_Notice::instance();
    }
endif;
/**
 * Returns an instance of the PWH_DCFH_File_Helpers class.
 * This function ensures that only one instance of the PWH_DCFH_File_Helpers class is created.
 * If the class has already been instantiated, it returns the existing instance.
 * @return PWH_DCFH_File_Helpers An instance of the PWH_DCFH_File_Helpers class.
 */
if (!function_exists('pwh_dcfh_file_helpers')):
    function pwh_dcfh_file_helpers()
    {
        return PWH_DCFH_File_Helpers::instance();
    }
endif;
/**
 * Checks if the function 'pwh_dcfh_logger' exists, and if not, defines it.
 * This function returns an instance of the 'PWH_DCFH_Logger' class.
 * @return PWH_DCFH_Logger An instance of the 'PWH_DCFH_Logger' class.
 */
if (!function_exists('pwh_dcfh_logger')):
    function pwh_dcfh_logger()
    {
        return PWH_DCFH_Logger::instance();
    }
endif;
/**
 * Returns an instance of the PWH_DCFH_DB class.
 * This function is used to retrieve an instance of the PWH_DCFH_DB class
 * for performing database operations within the context of the PWH_DCFH_DB
 * framework.
 * @return PWH_DCFH_DB An instance of the PWH_DCFH_DB class.
 */
if (!function_exists('pwh_dcfh_db')):
    function pwh_dcfh_db()
    {
        return PWH_DCFH_DB::instance();
    }
endif;
/**
 * Checks if the function 'pwh_dcfh_post_meta_handler' does not already exist, and defines it if not.
 * This function returns an instance of the 'PWH_DCFH_Post_Meta_Handler' class.
 * @return PWH_DCFH_Post_Meta_Handler An instance of the 'PWH_DCFH_Post_Meta_Handler' class.
 */
if (!function_exists('pwh_dcfh_post_meta_handler')):
    function pwh_dcfh_post_meta_handler()
    {
        return PWH_DCFH_Post_Meta_Handler::instance();
    }
endif;
/**
 * Checks if the function 'pwh_dcfh_user_handler' does not already exist,
 * and defines it if not.
 * This function returns an instance of the 'PWH_DCFH_User_Handler' class.
 * @return PWH_DCFH_User_Handler The instance of the 'PWH_DCFH_User_Handler' class.
 */
if (!function_exists('pwh_dcfh_user_handler')):
    function pwh_dcfh_user_handler()
    {
        return PWH_DCFH_User_Handler::instance();
    }
endif;
/**
 * Retrieves the instance of the PWH_DCFH_Email_Merge_Tags_Handler class.
 * If the function does not exist, it defines the function to return the instance.
 * @return PWH_DCFH_Email_Merge_Tags_Handler The instance of the PWH_DCFH_Email_Merge_Tags_Handler class.
 */
if (!function_exists('pwh_dcfh_email_merge_tags_handler')):
    function pwh_dcfh_email_merge_tags_handler()
    {
        return PWH_DCFH_Email_Merge_Tags_Handler::instance();
    }
endif;
/**
 * Retrieves an instance of the PWH_DCFH_Email_Template_Handler class.
 * If the function does not already exist, it defines the function
 * to return an instance of the PWH_DCFH_Email_Template_Handler class.
 * @return PWH_DCFH_Email_Template_Handler An instance of the PWH_DCFH_Email_Template_Handler class.
 */
if (!function_exists('pwh_dcfh_email_tpl_handler')):
    function pwh_dcfh_email_tpl_handler()
    {
        return PWH_DCFH_Email_Template_Handler::instance();
    }
endif;
/**
 * Debugging function for displaying data and optionally exiting.
 * This function displays the provided data and optionally exits the script.
 *
 * @param mixed $data The data to be displayed for debugging.
 * @param bool $exit Optional. Whether to exit the script after displaying the data. Default is true.
 *
 * @return void
 */
if (!function_exists('pwh_dcfh_dd')):
    /**
     * @param $data
     * @param bool $exit
     *
     * @return void
     */
    function pwh_dcfh_dd($data = '', $exit = true)
    {
        pwh_dcfh_helpers()::dd($data, $exit);
    }
endif;
/**
 * Logs data using pwh_dcfh_helpers::log method.
 * This function logs data using the pwh_dcfh_helpers::log method.
 * If the method does not exist,
 * it does nothing.
 *
 * @param mixed $data The data to be logged.
 * @param bool $delete Optional. Whether to delete the log file after logging. Default is false.
 * @param string $file_name Optional. The name of the log file. Default is an empty string.
 *
 * @return void
 */
if (!function_exists('pwh_dcfh_log')):
    function pwh_dcfh_log($data, $delete = false, $file_name = '')
    {
        pwh_dcfh_helpers()::log($data, $delete, $file_name);
    }
endif;
/**
 * Sends a confirmation email for the "pwh_dcfh" plugin.
 * This function triggers an action hook 'pwh_dcfh_confirmation_email'
 * which can be used by other functions or plugins to hook into the email
 * sending process and modify or extend its behavior.
 *
 * @param bool $is_sent Indicates whether the email has been successfully sent.
 * @param string $to The email address of the recipient.
 * @param string $cc The email addresses to be CC'd.
 * @param string $bcc The email addresses to be BCC'd.
 * @param string $subject The subject line of the email.
 * @param string $body The body content of the email.
 * @param string $from The email address of the sender.
 * @param array $extra Any extra parameters or data relevant to the email.
 */
if (!function_exists('pwh_dcfh_confirmation_email')):
    function pwh_dcfh_confirmation_email($is_sent, $to, $cc, $bcc, $subject, $body, $from, $extra)
    {
        do_action('pwh_dcfh_confirmation_email', $is_sent, $to, $cc, $bcc, $subject, $body, $from, $extra);
    }
endif;