diff --git a/src/Core/CHANGELOG.md b/src/Core/CHANGELOG.md index d52dc683b..cce344c16 100644 --- a/src/Core/CHANGELOG.md +++ b/src/Core/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 0.5.1 + +### Added + +- Add `Configuration::isDefault` methods. + ## 0.5.0 ### Added diff --git a/src/Core/src/Configuration.php b/src/Core/src/Configuration.php index 8f3ef5fce..8d0abf271 100644 --- a/src/Core/src/Configuration.php +++ b/src/Core/src/Configuration.php @@ -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]; + } } diff --git a/src/Core/tests/Unit/ConfigurationTest.php b/src/Core/tests/Unit/ConfigurationTest.php index 94d1a86d5..f14bbca07 100644 --- a/src/Core/tests/Unit/ConfigurationTest.php +++ b/src/Core/tests/Unit/ConfigurationTest.php @@ -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']];