<?php

namespace classes;

require_once WD . '/modules/selfserve/selfserve_c.php';
require_once WD . '/modules/selfserve/classes/selfserve_lane.php';


/**
 * Actions
 */


use Exception;
use interfaces\universal_module_i;
use modules\selfserve\classes\selfserve_lane;
use modules\selfserve\selfserve_c;

class selfserve implements universal_module_i
{
    /**
     * The configuration of the module
     * @var selfserve_c
     */
    public selfserve_c $config;

    public function __construct()
    {
        $this->config = new selfserve_c();
    }

    public static function getInstance(): self
    {
        return new self();
    }

    public static function standardize_registration(string $reg): string
    {
        // Remove spaces and convert to uppercase
        // Return the standardized registration
        return strtoupper(str_replace(' ', '', $reg));
    }

    public function lane(int $lane_id): selfserve_lane
    {
        return new selfserve_lane($lane_id);
    }

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