<?php

namespace classes;

require_once WD . '/modules/xlvask/xlvask_c.php';
require_once WD . '/modules/xlvask/classes/xlvask_endpoints.php';
require_once WD . '/modules/xlvask/xlvask_helpers.php';


/**
 * Actions
 */


use Exception;
use helpers\xlvask_cache;
use helpers\xlvask_guid;
use helpers\xlvask_tasks;
use interfaces\xlvask_i;
use xlvask\classes\xlvask_endpoints;
use xlvask\xlvask_c;
use xlvask\xlvask_helpers;

class xlvask extends xlvask_endpoints implements xlvask_i
{
    /**
     * The configuration of the xlvask module
     * @var xlvask_c
     */
    public xlvask_c $config;
    /**
     * The tasks helper for the xlvask module
     * @var xlvask_helpers
     */
    public xlvask_helpers $helpers;

    public function __construct()
    {
        $this->config = new xlvask_c();
        $this->helpers = new xlvask_helpers();
    }


    /**
     * @inheritDoc
     */
    public function requireModuleEnabled(): void
    {
        if (!(bool)$this->config->enabled->getVariableValue()) {
            throw new Exception('xlvask module is not enabled');
        }
    }

    /**
     * Get the task helper for the xlvask module
     * @return xlvask_tasks
     */
    public function getTasks(): xlvask_tasks
    {
        return new $this->helpers->xlvask_tasks();
    }

    /**
     * Get the cache helper for the xlvask module
     * @return xlvask_cache
     */
    public function getCache(): \helpers\xlvask_cache
    {
        return new $this->helpers->xlvask_cache();
    }

    /**
     * Get the guid helper for the xlvask module
     * @return xlvask_guid
     */
    public function getGuid(): xlvask_guid
    {
        return new $this->helpers->xlvask_guid();
    }

    /**
     * Create a new instance of a helper class
     * @param string $helper_class The class name of the helper to create
     * @throws Exception If the helper class does not exist or is not a valid helper.
     */
    public function new(string $helper_class): \helpers\xlvask_vehicle_types|\helpers\xlvask_usage_log|\helpers\xlvask_customer|xlvask_cache|xlvask_tasks|\helpers\xlvask_wash_item|\helpers\xlvask_create_customer|\helpers\xlvask_helper|\helpers\xlvask_vehicle_type|\helpers\xlvask_vehicle|\helpers\xlvask_vehicles|xlvask_guid
    {
        return $this->helpers->new($helper_class);
    }
}