<?php
/**
 * @package         Conditions
 * @version         23.1.9739
 * 
 * @author          Peter van Westen <info@regularlabs.com>
 * @link            http://regularlabs.com
 * @copyright       Copyright © 2023 Regular Labs All Rights Reserved
 * @license         http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 */

namespace RegularLabs\Component\Conditions\Administrator\Condition\Date;

defined('_JEXEC') or die;

use RegularLabs\Component\Conditions\Administrator\Condition\Condition;
use RegularLabs\Component\Conditions\Administrator\Condition\HasArraySelection;
use RegularLabs\Component\Conditions\Administrator\Helper\Date as DateHelper;

class Day extends Condition
{
    use HasArraySelection;

    public function pass()
    {
        $current_day = (int) DateHelper::getString('', 'N');  // 1 (for Monday) though 7 (for Sunday )

        foreach ($this->selection as &$day)
        {
            $day = DateHelper::getDayNumber($day);
        }

        return $this->passSimple($current_day);
    }
}
