<?php

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

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

/**
 * All the checkers must match for this composite to return true.
 */
class TimeCheckerANDComposite extends TimeCheckerComposite implements CheckableTime
{
    public function matches(Carbon $date): bool
    {
        // rather easy
        foreach ($this->timeCheckers as $checker) {
            if (!$checker->matches($date)) {
                return false;
            }
        }

        return true;
    }
}