File tree Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ public function __construct(
2222 if (!$ from && !$ to ) {
2323 throw new NotCompliant ('Date intervals: from ' . $ from . ' to ' . $ to );
2424 }
25+ if ($ from && $ to && $ from ->time > $ to ->time ) {
26+ throw new NotCompliant ('From can be after To : ' . $ from . '/ ' . $ to );
27+ }
2528
2629 $ this ->calculateDuration ();
2730 }
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ public function __construct(
2222 if (!$ from && !$ to ) {
2323 throw new NotCompliant ('Date time intervals: from ' . $ from . ' to ' . $ to );
2424 }
25+ if ($ from && $ to && $ from ->time > $ to ->time ) {
26+ throw new NotCompliant ('From can be after To : ' . $ from . '/ ' . $ to );
27+ }
2528
2629 $ this ->calculateDuration ();
2730 }
Original file line number Diff line number Diff line change @@ -252,4 +252,14 @@ public function testNotCompliant(): void
252252
253253 new DateInterval (null , null );
254254 }
255+
256+ public function testNotCompliantDateInvert (): void
257+ {
258+ $ this ->expectException (NotCompliant::class);
259+
260+ DateInterval::make (
261+ '1970-01-01 ' ,
262+ '1954-06-07 '
263+ );
264+ }
255265}
Original file line number Diff line number Diff line change @@ -252,4 +252,14 @@ public function testNotCompliant(): void
252252
253253 new DateTimeInterval (null , null );
254254 }
255+
256+ public function testNotCompliantDateInvert (): void
257+ {
258+ $ this ->expectException (NotCompliant::class);
259+
260+ DateTimeInterval::make (
261+ '1970-01-01 00:00:00 ' ,
262+ '1954-06-07 12:34:56 '
263+ );
264+ }
255265}
You can’t perform that action at this time.
0 commit comments