diff --git a/composer.json b/composer.json index fe8dff3..4764058 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "require": { "php": ">=8.1", "myclabs/deep-copy": "^1.11", - "programmatordev/php-api-sdk": "^0.2.0", + "programmatordev/php-api-sdk": "^1.0", "programmatordev/yet-another-php-validator": "^1.1" }, "require-dev": { diff --git a/docs/05-entities.md b/docs/05-entities.md index 412e901..5b136e2 100644 --- a/docs/05-entities.md +++ b/docs/05-entities.md @@ -27,8 +27,6 @@ - [Condition](#condition) - [Icon](#icon) - [Location](#location) - - [MoonPhase](#moonphase) - - [Temperature](#temperature) - [Timezone](#timezone) - [Wind](#wind) diff --git a/src/OpenWeatherMap.php b/src/OpenWeatherMap.php index 427f5b0..845c29c 100644 --- a/src/OpenWeatherMap.php +++ b/src/OpenWeatherMap.php @@ -62,7 +62,6 @@ private function configureOptions(array $options): array $this->optionsResolver->setAllowedTypes('language', 'string'); $this->optionsResolver->setAllowedValues('unitSystem', UnitSystem::getOptions()); - $this->optionsResolver->setAllowedValues('language', Language::getOptions()); return $this->optionsResolver->resolve($options); } @@ -76,7 +75,7 @@ private function configureApi(): void $this->addQueryDefault('units', $this->options['unitSystem']); $this->addQueryDefault('lang', $this->options['language']); - $this->addPostRequestHandler(function(PostRequestEvent $event) { + $this->addPostRequestListener(function(PostRequestEvent $event) { $response = $event->getResponse(); $statusCode = $response->getStatusCode(); @@ -94,7 +93,7 @@ private function configureApi(): void } }); - $this->addResponseContentsHandler(function(ResponseContentsEvent $event) { + $this->addResponseContentsListener(function(ResponseContentsEvent $event) { // decode json string response into an array $contents = $event->getContents(); $contents = \json_decode($contents, true); diff --git a/src/Resource/Util/LanguageTrait.php b/src/Resource/Util/LanguageTrait.php index 76e6493..fecfad7 100644 --- a/src/Resource/Util/LanguageTrait.php +++ b/src/Resource/Util/LanguageTrait.php @@ -2,20 +2,12 @@ namespace ProgrammatorDev\OpenWeatherMap\Resource\Util; -use ProgrammatorDev\Validator\Exception\ValidationException; use function DeepCopy\deep_copy; trait LanguageTrait { - use ValidationTrait; - - /** - * @throws ValidationException - */ public function withLanguage(string $language): static { - $this->validateLanguage($language); - $clone = deep_copy($this, true); $clone->api->addQueryDefault('lang', $language); diff --git a/tests/Integration/LanguageTraitTest.php b/tests/Integration/LanguageTraitTest.php index 2419017..79651ee 100644 --- a/tests/Integration/LanguageTraitTest.php +++ b/tests/Integration/LanguageTraitTest.php @@ -5,7 +5,6 @@ use ProgrammatorDev\OpenWeatherMap\Resource\Resource; use ProgrammatorDev\OpenWeatherMap\Resource\Util\LanguageTrait; use ProgrammatorDev\OpenWeatherMap\Test\AbstractTest; -use ProgrammatorDev\Validator\Exception\ValidationException; class LanguageTraitTest extends AbstractTest { @@ -30,10 +29,4 @@ public function testMethods(): void $this->assertSame('pt', $this->resource->withLanguage('pt')->getLanguage()); $this->assertSame('en', $this->resource->getLanguage()); // back to default value } - - public function testValidationException(): void - { - $this->expectException(ValidationException::class); - $this->resource->withLanguage('invalid'); - } } \ No newline at end of file