<?php

namespace modules\selfserve\classes;
require_once WD . '/modules/selfserve/interfaces/selfserve_lane_i.php';
require_once WD . '/modules/selfserve/traits/selfserve_lane_cache_t.php';
require_once WD . '/modules/selfserve/traits/selfserve_lane_mode_t.php';
require_once WD . '/modules/selfserve/traits/selfserve_lane_state_t.php';
require_once WD . '/modules/selfserve/traits/selfserve_lane_status_t.php';
require_once WD . '/modules/selfserve/traits/selfserve_lane_port_controller_t.php';
require_once WD . '/modules/selfserve/traits/selfserve_lane_command_t.php';
require_once WD . '/modules/selfserve/traits/selfserve_lane_timer_t.php';
require_once WD . '/modules/selfserve/traits/selfserve_lane_license_plate_t.php';
require_once WD . '/modules/selfserve/traits/selfserve_lane_customer_number_t.php';
require_once WD . '/modules/selfserve/traits/selfserve_lane_invoice_t.php';
require_once WD . '/modules/selfserve/traits/selfserve_lane_reservation_timer_t.php';
require_once WD . '/modules/selfserve/traits/selfserve_lane_relay_controller_t.php';
require_once WD . '/modules/selfserve/traits/selfserve_lane_log_t.php';

use modules\selfserve\interfaces\selfserve_lane_i;
use modules\selfserve\traits\selfserve_lane_cache_t;
use modules\selfserve\traits\selfserve_lane_command_t;
use modules\selfserve\traits\selfserve_lane_customer_number_t;
use modules\selfserve\traits\selfserve_lane_invoice_t;
use modules\selfserve\traits\selfserve_lane_license_plate_t;
use modules\selfserve\traits\selfserve_lane_log_t;
use modules\selfserve\traits\selfserve_lane_mode_t;
use modules\selfserve\traits\selfserve_lane_port_controller_t;
use modules\selfserve\traits\selfserve_lane_reservation_timer_t;
use modules\selfserve\traits\selfserve_lane_state_t;
use modules\selfserve\traits\selfserve_lane_status_t;
use modules\selfserve\traits\selfserve_lane_timer_t;
use modules\selfserve\traits\selfserve_lane_relay_controller_t;

class selfserve_lane implements selfserve_lane_i
{
    use selfserve_lane_status_t,
        selfserve_lane_mode_t,
        selfserve_lane_state_t,
        selfserve_lane_cache_t,
        selfserve_lane_port_controller_t,
        selfserve_lane_command_t,
        selfserve_lane_timer_t,
        selfserve_lane_license_plate_t,
        selfserve_lane_customer_number_t,
        selfserve_lane_invoice_t,
        selfserve_lane_reservation_timer_t,
        selfserve_lane_relay_controller_t,
        selfserve_lane_log_t;

    /**
     * @throws \Exception
     */
    public function __construct(int $lane_id)
    {
        $this->id = $lane_id;
        $this->department_lane = (new \objects\department_lanes_o())->select($lane_id);
        // Raise exception if department lane not found
        if (!$this->department_lane->exists()) {
            throw new \Exception("Department lane not found for lane ID {$lane_id}");
        }
    }

    /**
     * The lane ID
     * @var int $id
     * @see \objects\department_lanes_o
     */
    public int $id;
    /**
     * Bypass customer number validation flag
     * @var bool $bypass_customer_number_validation
     */
    public bool $bypass_customer_number_validation = false;
    /**
     * Department lane object
     * @var \objects\department_lanes_o|null $department_lane
     */
    public ?\objects\department_lanes_o $department_lane = null;

    public function isBypassCustomerNumberValidation(): bool
    {
        return $this->bypass_customer_number_validation;
    }

    public function setBypassCustomerNumberValidation(bool $bypass): void
    {
        $this->bypass_customer_number_validation = $bypass;
    }
}