<?php
/**
 * BookiFlex Core
 *
 * @package    BookiFlex
 * @subpackage Core
 * @author     BookiFlex
 * @copyright  Copyright (c) 2025 BookiFlex
 * @license    GPL-2.0-or-later
 *
 * @link       https://bookiflex.com
 */

declare(strict_types=1);

namespace BookiFlex\Core\Model\RatePlan;

use BookiFlex\Core\Model\DateUnit\DateUnitTypeInterface;
use BookiFlex\Core\Model\DateUnit\InheritanceRestrictionRulesInterface;

defined( 'ABSPATH' ) || exit;

class InheritanceRestrictionRules implements \JsonSerializable, InheritanceRestrictionRulesInterface
{
    private array $array = [
        DateUnitTypeInterface::STOP_SALE_TYPE       => false,
        DateUnitTypeInterface::MIN_LOS_TYPE         => false,
        DateUnitTypeInterface::MAX_LOS_TYPE         => false,
        DateUnitTypeInterface::MIN_LOS_ARRIVAL_TYPE => false,
        DateUnitTypeInterface::MAX_LOS_ARRIVAL_TYPE => false,
        DateUnitTypeInterface::MIN_ADV_BOOKING_TYPE => false,
        DateUnitTypeInterface::MAX_ADV_BOOKING_TYPE => false,
        DateUnitTypeInterface::CTA_TYPE             => false,
        DateUnitTypeInterface::CTD_TYPE             => false,
    ];

    public function __construct(array $restrictions = [])
    {
        foreach ($restrictions as $v) {
            if (!key_exists($v, $this->array)) {
                continue;
            }

            $this->array[$v] = true;
        }
    }

    #[\ReturnTypeWillChange]
    public function jsonSerialize()
    {
        return $this->array;
    }

    public function inheritStopSale(): bool
    {
        return $this->array[DateUnitTypeInterface::STOP_SALE_TYPE];
    }

    public function inheritMinLengthOfStay(): bool
    {
        return $this->array[DateUnitTypeInterface::MIN_LOS_TYPE];
    }

    public function inheritMaxLengthOfStay(): bool
    {
        return $this->array[DateUnitTypeInterface::MAX_LOS_TYPE];
    }

    public function inheritMinLengthOfStayArrival(): bool
    {
        return $this->array[DateUnitTypeInterface::MIN_LOS_ARRIVAL_TYPE];
    }

    public function inheritMaxLengthOfStayArrival(): bool
    {
        return $this->array[DateUnitTypeInterface::MAX_LOS_ARRIVAL_TYPE];
    }

    public function inheritMinAdvBooking(): bool
    {
        return $this->array[DateUnitTypeInterface::MIN_ADV_BOOKING_TYPE];
    }

    public function inheritMaxAdvBooking(): bool
    {
        return $this->array[DateUnitTypeInterface::MAX_ADV_BOOKING_TYPE];
    }

    public function inheritCloseToArrival(): bool
    {
        return $this->array[DateUnitTypeInterface::CTA_TYPE];
    }

    public function inheritCloseToDeparture(): bool
    {
        return $this->array[DateUnitTypeInterface::CTD_TYPE];
    }
}
