Skip to content

Commit

Permalink
Restore is default method (async-aws#482)
Browse files Browse the repository at this point in the history
* Restore is default method

* Add changelog entry
  • Loading branch information
jderusse authored Apr 12, 2020
1 parent e6f5d92 commit 6ce4bab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 0.5.1

### Added

- Add `Configuration::isDefault` methods.

## 0.5.0

### Added
Expand Down
9 changes: 9 additions & 0 deletions src/Core/src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,13 @@ public function has(string $name): bool

return isset($this->data[$name]);
}

public function isDefault(string $name): bool
{
if (!isset(self::AVAILABLE_OPTIONS[$name])) {
throw new InvalidArgument(\sprintf('Invalid option "%s" passed to "%s::%s". ', $name, __CLASS__, __METHOD__));
}

return isset($this->data[$name], self::DEFAULT_OPTIONS[$name]) && $this->data[$name] === self::DEFAULT_OPTIONS[$name];
}
}
8 changes: 8 additions & 0 deletions src/Core/tests/Unit/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ public function testCreate($config, $env, $expected)
}
}

public function testIsDefault()
{
$config = Configuration::create(['region' => 'eu-west-3']);

self::assertTrue($config->isDefault('endpoint'));
self::assertFalse($config->isDefault('region'));
}

public function provideConfiguration(): iterable
{
yield 'simple config' => [['endpoint' => 'foo'], [], ['endpoint' => 'foo']];
Expand Down

0 comments on commit 6ce4bab

Please sign in to comment.