Skip to content

Commit d74c981

Browse files
authored
Merge pull request #59 from programmatordev/2.x
v2.0.0
2 parents ccfaf1d + e1303b4 commit d74c981

File tree

5 files changed

+3
-21
lines changed

5 files changed

+3
-21
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"require": {
1515
"php": ">=8.1",
1616
"myclabs/deep-copy": "^1.11",
17-
"programmatordev/php-api-sdk": "^0.2.0",
17+
"programmatordev/php-api-sdk": "^1.0",
1818
"programmatordev/yet-another-php-validator": "^1.1"
1919
},
2020
"require-dev": {

docs/05-entities.md

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
- [Condition](#condition)
2828
- [Icon](#icon)
2929
- [Location](#location)
30-
- [MoonPhase](#moonphase)
31-
- [Temperature](#temperature)
3230
- [Timezone](#timezone)
3331
- [Wind](#wind)
3432

src/OpenWeatherMap.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ private function configureOptions(array $options): array
6262
$this->optionsResolver->setAllowedTypes('language', 'string');
6363

6464
$this->optionsResolver->setAllowedValues('unitSystem', UnitSystem::getOptions());
65-
$this->optionsResolver->setAllowedValues('language', Language::getOptions());
6665

6766
return $this->optionsResolver->resolve($options);
6867
}
@@ -76,7 +75,7 @@ private function configureApi(): void
7675
$this->addQueryDefault('units', $this->options['unitSystem']);
7776
$this->addQueryDefault('lang', $this->options['language']);
7877

79-
$this->addPostRequestHandler(function(PostRequestEvent $event) {
78+
$this->addPostRequestListener(function(PostRequestEvent $event) {
8079
$response = $event->getResponse();
8180
$statusCode = $response->getStatusCode();
8281

@@ -94,7 +93,7 @@ private function configureApi(): void
9493
}
9594
});
9695

97-
$this->addResponseContentsHandler(function(ResponseContentsEvent $event) {
96+
$this->addResponseContentsListener(function(ResponseContentsEvent $event) {
9897
// decode json string response into an array
9998
$contents = $event->getContents();
10099
$contents = \json_decode($contents, true);

src/Resource/Util/LanguageTrait.php

-8
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,12 @@
22

33
namespace ProgrammatorDev\OpenWeatherMap\Resource\Util;
44

5-
use ProgrammatorDev\Validator\Exception\ValidationException;
65
use function DeepCopy\deep_copy;
76

87
trait LanguageTrait
98
{
10-
use ValidationTrait;
11-
12-
/**
13-
* @throws ValidationException
14-
*/
159
public function withLanguage(string $language): static
1610
{
17-
$this->validateLanguage($language);
18-
1911
$clone = deep_copy($this, true);
2012
$clone->api->addQueryDefault('lang', $language);
2113

tests/Integration/LanguageTraitTest.php

-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use ProgrammatorDev\OpenWeatherMap\Resource\Resource;
66
use ProgrammatorDev\OpenWeatherMap\Resource\Util\LanguageTrait;
77
use ProgrammatorDev\OpenWeatherMap\Test\AbstractTest;
8-
use ProgrammatorDev\Validator\Exception\ValidationException;
98

109
class LanguageTraitTest extends AbstractTest
1110
{
@@ -30,10 +29,4 @@ public function testMethods(): void
3029
$this->assertSame('pt', $this->resource->withLanguage('pt')->getLanguage());
3130
$this->assertSame('en', $this->resource->getLanguage()); // back to default value
3231
}
33-
34-
public function testValidationException(): void
35-
{
36-
$this->expectException(ValidationException::class);
37-
$this->resource->withLanguage('invalid');
38-
}
3932
}

0 commit comments

Comments
 (0)