1212use ProgrammatorDev \OpenWeatherMap \Exception \TooManyRequestsException ;
1313use ProgrammatorDev \OpenWeatherMap \Exception \UnauthorizedException ;
1414use ProgrammatorDev \OpenWeatherMap \Exception \UnexpectedErrorException ;
15- use ProgrammatorDev \OpenWeatherMap \Exception \ValidationException ;
1615use ProgrammatorDev \OpenWeatherMap \Validator \CoordinateValidatorTrait ;
1716use ProgrammatorDev \OpenWeatherMap \Validator \GreaterThanValidatorTrait ;
17+ use ProgrammatorDev \YetAnotherPhpValidator \Exception \ValidationException ;
18+ use ProgrammatorDev \YetAnotherPhpValidator \Validator ;
1819
1920class WeatherEndpoint extends AbstractEndpoint
2021{
@@ -40,7 +41,8 @@ class WeatherEndpoint extends AbstractEndpoint
4041 */
4142 public function getCurrent (float $ latitude , float $ longitude ): WeatherLocation
4243 {
43- $ this ->validateCoordinate ($ latitude , $ longitude );
44+ Validator::range (-90 , 90 )->assert ($ latitude , 'latitude ' );
45+ Validator::range (-180 , 180 )->assert ($ longitude , 'longitude ' );
4446
4547 $ data = $ this ->sendRequest (
4648 method: 'GET ' ,
@@ -67,8 +69,9 @@ public function getCurrent(float $latitude, float $longitude): WeatherLocation
6769 */
6870 public function getForecast (float $ latitude , float $ longitude , int $ numResults = self ::NUM_RESULTS ): WeatherLocationList
6971 {
70- $ this ->validateCoordinate ($ latitude , $ longitude );
71- $ this ->validateGreaterThan ('numResults ' , $ numResults , 0 );
72+ Validator::range (-90 , 90 )->assert ($ latitude , 'latitude ' );
73+ Validator::range (-180 , 180 )->assert ($ longitude , 'longitude ' );
74+ Validator::greaterThan (0 )->assert ($ numResults , 'numResults ' );
7275
7376 $ data = $ this ->sendRequest (
7477 method: 'GET ' ,
0 commit comments