Change has to isSet
This commit is contained in:
@@ -30,6 +30,6 @@ interface MetadataInterface
|
||||
*
|
||||
* @return bool `true` if the key is set (regardless of what the value is), otherwise `false`.
|
||||
*/
|
||||
public function has(string $key): bool;
|
||||
public function isSet(string $key): bool;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ final class Metadata implements MetadataInterface
|
||||
|
||||
public function get(string $key): mixed
|
||||
{
|
||||
if (!$this->has($key)) {
|
||||
if (!$this->isSet($key)) {
|
||||
throw new MissingKeyException($key);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ final class Metadata implements MetadataInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function has(string $key): bool
|
||||
public function isSet(string $key): bool
|
||||
{
|
||||
return array_key_exists($key, $this->metadata);
|
||||
}
|
||||
|
||||
@@ -47,17 +47,17 @@ final class MetadataTest extends TestCase
|
||||
$this->assertSame($valueB, $result);
|
||||
}
|
||||
|
||||
public function testHasReturnsTrueWhenKeyIsSet(): void
|
||||
public function testIsSetReturnsTrueWhenKeyIsSet(): void
|
||||
{
|
||||
$key = 'null';
|
||||
$this->metadata->set($key, null);
|
||||
$result = $this->metadata->has($key);
|
||||
$result = $this->metadata->isSet($key);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testHasReturnsFalseWhenKeyIsNotSet(): void
|
||||
public function testIsSetReturnsFalseWhenKeyIsNotSet(): void
|
||||
{
|
||||
$result = $this->metadata->has('missing');
|
||||
$result = $this->metadata->isSet('missing');
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user