Skip to content

Commit 4b3efa3

Browse files
authored
Restore is default method (#482)
* Restore is default method * Add changelog entry
1 parent ddfcf0c commit 4b3efa3

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## 0.5.1
4+
5+
### Added
6+
7+
- Add `Configuration::isDefault` methods.
8+
39
## 0.5.0
410

511
### Added

src/Configuration.php

+9
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,13 @@ public function has(string $name): bool
126126

127127
return isset($this->data[$name]);
128128
}
129+
130+
public function isDefault(string $name): bool
131+
{
132+
if (!isset(self::AVAILABLE_OPTIONS[$name])) {
133+
throw new InvalidArgument(\sprintf('Invalid option "%s" passed to "%s::%s". ', $name, __CLASS__, __METHOD__));
134+
}
135+
136+
return isset($this->data[$name], self::DEFAULT_OPTIONS[$name]) && $this->data[$name] === self::DEFAULT_OPTIONS[$name];
137+
}
129138
}

tests/Unit/ConfigurationTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ public function testCreate($config, $env, $expected)
3030
}
3131
}
3232

33+
public function testIsDefault()
34+
{
35+
$config = Configuration::create(['region' => 'eu-west-3']);
36+
37+
self::assertTrue($config->isDefault('endpoint'));
38+
self::assertFalse($config->isDefault('region'));
39+
}
40+
3341
public function provideConfiguration(): iterable
3442
{
3543
yield 'simple config' => [['endpoint' => 'foo'], [], ['endpoint' => 'foo']];

0 commit comments

Comments
 (0)