<?php

/**
 * HappyFenceNG Total Enterprise Security Plugin
 * HAPPYWPRESS is a RazorVue Trademark.
 *
 * @package     HappyFenceNG
 * @developer   Simonluca Scillitani
 * @copyright   2025 RazorVue di Scillitani Simonluca
 * @link        https://razorvue.it
 * @author      RazorVue di Scillitani Simonluca
 * @brand       HappyWPress
 * @uri         https://happywpress.com
 * @set all
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
/**PHPCS -> code compliance: we put useful comments where needed.. */
class HappyFenceNGCStoreBuilder extends HappyFenceNGRuntimeExceptions {
    /**PHPCS -> code compliance: we put useful comments where needed..
     *
     * @param string $table ...the name.
     */
    private static function tableExist( $table ) : bool {
        global $wpdb;
        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery
        return HappyFenceNGPROC::equals( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table ) ), $table );
    }

    /**PHPCS -> code compliance: we put useful comments where needed.. */
    public static function checkAndBuild() {
        if ( !self::tableExist( HappyFenceNGStStored::get_c_store_table_name() ) ) {
            HappyFenceNGCStore::init();
        }
        if ( !self::tableExist( HappyFenceNGStStored::get_b_store_table_name() ) ) {
            HappyFenceNGBStore::init();
        }
    }

}
