<?php

namespace SugarCalendarBookings\Availability;

use DateTimeZone;
use SugarCalendarBookings\Employees\EmployeeModel;

/**
 * Abstract working schedule rule.
 *
 * Represents a single working schedule rule for an employee.
 *
 * Examples:
 * - Weekday rule: on Monday, the employee works from 10:00 to 14:00 and from 15:00 to 18:00.
 * - Date range rule: from 2025-01-01 to 2025-01-31, the employee works from 10:00 to 18:00.
 *
 * @since 1.0.0
 */
abstract class AbstractWorkingScheduleRule {

	/**
	 * Periods.
	 *
	 * @since 1.0.0
	 *
	 * @var array<WorkingPeriodRule> Periods.
	 */
	private $periods;

	/**
	 * Time zone.
	 *
	 * @since 1.0.0
	 *
	 * @var DateTimeZone Time zone.
	 */
	private $time_zone;

	/**
	 * Employee model.
	 *
	 * The owner of the working schedule rule.
	 *
	 * @since 1.0.0
	 *
	 * @var EmployeeModel Employee model.
	 */
	private $employee;

	/**
	 * Priority.
	 *
	 * Mainly used to distinguish beetwen regular rules and overrides.
	 * Overrides have higher priority.
	 *
	 * @since 1.0.0
	 *
	 * @var int Priority.
	 */
	private $priority;

	/**
	 * Constructor.
	 *
	 * @since 1.0.0
	 *
	 * @param array<WorkingPeriodRule> $periods   Periods.
	 * @param DateTimeZone             $time_zone Time zone.
	 * @param EmployeeModel            $employee  Employee model.
	 * @param int                      $priority  Priority.
	 */
	public function __construct( $periods, $time_zone, $employee, $priority ) {

		$this->periods   = $periods;
		$this->time_zone = $time_zone;
		$this->employee  = $employee;
		$this->priority  = $priority;
	}

	/**
	 * Get periods.
	 *
	 * @since 1.0.0
	 *
	 * @return array<WorkingPeriodRule> Periods.
	 */
	public function get_periods() {

		return $this->periods;
	}

	/**
	 * Get time zone.
	 *
	 * @since 1.0.0
	 *
	 * @return DateTimeZone Time zone.
	 */
	public function get_time_zone() {

		return $this->time_zone;
	}

	/**
	 * Get employee model.
	 *
	 * @since 1.0.0
	 *
	 * @return EmployeeModel Employee model.
	 */
	public function get_employee() {

		return $this->employee;
	}

	/**
	 * Get priority.
	 *
	 * @since 1.0.0
	 *
	 * @return int Priority.
	 */
	public function get_priority() {

		return $this->priority;
	}
}
