Skip to content

Commit b485207

Browse files
committed
Added logic exception if the sun set is before sun rise.
1 parent 2a682aa commit b485207

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Cmfcmf/OpenWeatherMap/Util/Sun.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ class Sun
3737
* @param \DateTime $rise The time of the sun rise
3838
* @param \DateTime $set The time of the sun set.
3939
*
40+
* @throws \LogicException If sunset is before sunrise.
4041
* @internal
4142
*/
4243
public function __construct(\DateTime $rise, \DateTime $set)
4344
{
45+
if ($set < $rise) {
46+
throw new \LogicException('Sunset cannot be before sunrise!');
47+
}
4448
$this->rise = $rise;
4549
$this->set = $set;
4650
}

0 commit comments

Comments
 (0)