<?php

namespace CouponsPlus\App\Conditions\BuiltIn\Conditions\Time;

use Carbon\Carbon;
use DateTimeInterface;
use CouponsPlus\App\Conditions\BuiltIn\Conditions\Time\Abilities\CheckableTime;

class WeekDayChecker implements CheckableTime
{
    /**
     * @var int (0-6, where 0 = Sunday)
     */
    protected int $day;

    public function __construct(int $day)
    {
        $this->day = $day;
    }

    public function matches(Carbon $date): bool
    {
        return $date->dayOfWeek === $this->day;
    }
}
