<?php

namespace NoahVet\Reef\Domain\Comparator;

use NoahVet\Reef\Domain\Tool\DateTool;

class DateComparator implements DateComparatorInterface
{
    #[\Override]
    public function endDateShouldBeTheLastDayOfTheYear(
        \DateTimeInterface $startDate,
        \DateTimeInterface $endDate,
    ): bool {
        return DateTool::toLastSecondOfTheYear($startDate) == $endDate;
    }

    #[\Override]
    public function endDateShouldBeGreaterThanOrEqualsToTheLastDayOfTheYear(
        \DateTimeInterface $startDate,
        \DateTimeInterface $endDate,
    ): bool {
        return DateTool::toLastSecondOfTheYear($startDate) >= $endDate;
    }

    #[\Override]
    public function periodShouldNotExceedOneYear(
        \DateTimeInterface $startDate,
        \DateTimeInterface $endDate,
    ): bool {
        return 0 === $startDate->diff($endDate)->y;
    }

    #[\Override]
    public function shouldBeGreaterThan(
        \DateTimeInterface $startDate,
        \DateTimeInterface $endDate,
    ): bool {
        return $startDate < $endDate;
    }

    #[\Override]
    public function shouldBeGreaterThanNow(
        \DateTimeInterface $date,
    ): bool {
        return $this->shouldBeGreaterThan(new \DateTime(), $date);
    }
}
