@@ -6,26 +6,26 @@ trait BetweenValidatorTrait
66{
77 private function ValidateBetween (
88 string $ name ,
9- \DateTimeImmutable |int |float $ value ,
10- \DateTimeImmutable |int |float $ startConstraint ,
11- \DateTimeImmutable |int |float $ endConstraint
9+ \DateTimeInterface |int |float $ value ,
10+ \DateTimeInterface |int |float $ startConstraint ,
11+ \DateTimeInterface |int |float $ endConstraint
1212 ): void
1313 {
1414 if (
15- $ value instanceof \DateTimeImmutable
16- && (!$ startConstraint instanceof \DateTimeImmutable || !$ endConstraint instanceof \DateTimeImmutable )
15+ $ value instanceof \DateTimeInterface
16+ && (!$ startConstraint instanceof \DateTimeInterface || !$ endConstraint instanceof \DateTimeInterface )
1717 ) {
18- throw new \LogicException ('Both $startConstraint and $endConstraint should be of type \DateTimeImmutable . ' );
18+ throw new \LogicException ('Both $startConstraint and $endConstraint should be of type \DateTimeInterface . ' );
1919 }
2020
2121 if (
22- !$ value instanceof \DateTimeImmutable
23- && ($ startConstraint instanceof \DateTimeImmutable || $ endConstraint instanceof \DateTimeImmutable )
22+ !$ value instanceof \DateTimeInterface
23+ && ($ startConstraint instanceof \DateTimeInterface || $ endConstraint instanceof \DateTimeInterface )
2424 ) {
2525 throw new \LogicException ('Both $startConstraint and $endConstraint should be of type int|float. ' );
2626 }
2727
28- if ($ value instanceof \DateTimeImmutable ) {
28+ if ($ value instanceof \DateTimeInterface ) {
2929 if ($ value ->getTimestamp () < $ startConstraint ->getTimestamp () || $ value ->getTimestamp () > $ endConstraint ->getTimestamp ()) {
3030 $ dateFormat = 'Y-m-d H:i:s ' ;
3131
0 commit comments