1010use ProgrammatorDev \OpenWeatherMap \Exception \TooManyRequestsException ;
1111use ProgrammatorDev \OpenWeatherMap \Exception \UnauthorizedException ;
1212use ProgrammatorDev \OpenWeatherMap \Exception \UnexpectedErrorException ;
13- use ProgrammatorDev \OpenWeatherMap \Exception \ValidationException ;
1413use ProgrammatorDev \OpenWeatherMap \Util \CreateEntityListTrait ;
15- use ProgrammatorDev \OpenWeatherMap \Validator \BlankValidatorTrait ;
16- use ProgrammatorDev \OpenWeatherMap \Validator \CoordinateValidatorTrait ;
17- use ProgrammatorDev \OpenWeatherMap \Validator \GreaterThanValidatorTrait ;
14+ use ProgrammatorDev \YetAnotherPhpValidator \Exception \ValidationException ;
15+ use ProgrammatorDev \YetAnotherPhpValidator \Validator ;
1816
1917class GeocodingEndpoint extends AbstractEndpoint
2018{
2119 use CreateEntityListTrait;
22- use BlankValidatorTrait;
23- use CoordinateValidatorTrait;
24- use GreaterThanValidatorTrait;
2520
2621 private const NUM_RESULTS = 5 ;
2722
@@ -45,8 +40,8 @@ class GeocodingEndpoint extends AbstractEndpoint
4540 */
4641 public function getByLocationName (string $ locationName , int $ numResults = self ::NUM_RESULTS ): array
4742 {
48- $ this -> validateBlank ( ' locationName ' , $ locationName );
49- $ this -> validateGreaterThan ( ' numResults ' , $ numResults , 0 );
43+ Validator:: notBlank ()-> assert ( $ locationName, ' locationName ' );
44+ Validator:: greaterThan ( 0 )-> assert ( $ numResults , ' numResults ' );
5045
5146 $ data = $ this ->sendRequest (
5247 method: 'GET ' ,
@@ -71,8 +66,8 @@ public function getByLocationName(string $locationName, int $numResults = self::
7166 */
7267 public function getByZipCode (string $ zipCode , string $ countryCode ): ZipCodeLocation
7368 {
74- $ this -> validateBlank ( ' zipCode ' , $ zipCode );
75- $ this -> validateBlank ( ' countryCode ' , $ countryCode );
69+ Validator:: notBlank ()-> assert ( $ zipCode, ' zipCode ' );
70+ Validator:: notBlank ()-> assert ( $ countryCode, ' countryCode ' );
7671
7772 $ data = $ this ->sendRequest (
7873 method: 'GET ' ,
@@ -97,8 +92,9 @@ public function getByZipCode(string $zipCode, string $countryCode): ZipCodeLocat
9792 */
9893 public function getByCoordinate (float $ latitude , float $ longitude , int $ numResults = self ::NUM_RESULTS ): array
9994 {
100- $ this ->validateCoordinate ($ latitude , $ longitude );
101- $ this ->validateGreaterThan ('numResults ' , $ numResults , 0 );
95+ Validator::range (-90 , 90 )->assert ($ latitude , 'latitude ' );
96+ Validator::range (-180 , 180 )->assert ($ longitude , 'longitude ' );
97+ Validator::greaterThan (0 )->assert ($ numResults , 'numResults ' );
10298
10399 $ data = $ this ->sendRequest (
104100 method: 'GET ' ,
0 commit comments