<?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\Service\DateUnit\DTO;

use BookiFlex\Core\Model\DateUnit\DateUnit;

defined( 'ABSPATH' ) || exit;

/**
 * Represents result of prepared sequence of DateUnits on the selected period.
 * With applied an inheritance and list of actual restrictions.
 */
class DateUnitsFinderResult
{
    /**
     * @param array|DateUnit[] $dateUnits
     * @param array|string[] $difference
     */
    public function __construct(
        private readonly array $dateUnits,
        private readonly bool  $isPeriodSequenced,
        private readonly array $restrictions = [],
        private readonly array $difference = []
    ) {
    }

    /**
     * @return DateUnit[]
     */
    public function getDateUnits(): array
    {
        return $this->dateUnits;
    }

    /**
     * Represents list of actual restriction on the given configuration.
     *
     * @return array
     */
    public function getActualRestrictions(): array
    {
        return $this->restrictions;
    }

    /**
     * Returns true if DateUnits are sequenced (or set in a row on each date of period).
     *
     * @return bool
     */
    public function isPeriodSequenced(): bool
    {
        return $this->isPeriodSequenced;
    }

    /**
     * If DateUnits are related to inherited rate plan, then it will return a list of dates
     * on which the parent DateUnit is set, and the inherited bfl is not found.
     *
     * @return string[]
     */
    public function getDateDifference(): array
    {
        return $this->difference;
    }
}
