1313use ProgrammatorDev \OpenWeatherMap \Exception \TooManyRequestsException ;
1414use ProgrammatorDev \OpenWeatherMap \Exception \UnauthorizedException ;
1515use ProgrammatorDev \OpenWeatherMap \Exception \UnexpectedErrorException ;
16- use ProgrammatorDev \OpenWeatherMap \Exception \ValidationException ;
1716use ProgrammatorDev \OpenWeatherMap \Validator \CoordinateValidatorTrait ;
1817use ProgrammatorDev \OpenWeatherMap \Validator \LessThanValidatorTrait ;
18+ use ProgrammatorDev \YetAnotherPhpValidator \Exception \ValidationException ;
19+ use ProgrammatorDev \YetAnotherPhpValidator \Validator ;
1920
2021class OneCallEndpoint extends AbstractEndpoint
2122{
@@ -41,7 +42,8 @@ class OneCallEndpoint extends AbstractEndpoint
4142 */
4243 public function getWeather (float $ latitude , float $ longitude ): OneCall
4344 {
44- $ this ->validateCoordinate ($ latitude , $ longitude );
45+ Validator::range (-90 , 90 )->assert ($ latitude , 'latitude ' );
46+ Validator::range (-180 , 180 )->assert ($ longitude , 'longitude ' );
4547
4648 $ data = $ this ->sendRequest (
4749 method: 'GET ' ,
@@ -68,8 +70,9 @@ public function getWeather(float $latitude, float $longitude): OneCall
6870 */
6971 public function getHistoryMoment (float $ latitude , float $ longitude , \DateTimeInterface $ dateTime ): WeatherLocation
7072 {
71- $ this ->validateCoordinate ($ latitude , $ longitude );
72- $ this ->validateLessThan ('dateTime ' , $ dateTime , new \DateTimeImmutable ('now ' ));
73+ Validator::range (-90 , 90 )->assert ($ latitude , 'latitude ' );
74+ Validator::range (-180 , 180 )->assert ($ longitude , 'longitude ' );
75+ Validator::lessThan (new \DateTime ('now ' ))->assert ($ dateTime , 'dateTime ' );
7376
7477 $ data = $ this ->sendRequest (
7578 method: 'GET ' ,
@@ -97,8 +100,9 @@ public function getHistoryMoment(float $latitude, float $longitude, \DateTimeInt
97100 */
98101 public function getHistoryAggregate (float $ latitude , float $ longitude , \DateTimeInterface $ date ): WeatherAggregate
99102 {
100- $ this ->validateCoordinate ($ latitude , $ longitude );
101- $ this ->validateLessThan ('date ' , $ date , new \DateTimeImmutable ('now ' ));
103+ Validator::range (-90 , 90 )->assert ($ latitude , 'latitude ' );
104+ Validator::range (-180 , 180 )->assert ($ longitude , 'longitude ' );
105+ Validator::lessThan (new \DateTime ('now ' ))->assert ($ date , 'date ' );
102106
103107 $ data = $ this ->sendRequest (
104108 method: 'GET ' ,
0 commit comments