Change has to isSet

This commit is contained in:
brabli
2025-11-27 15:17:14 +00:00
parent 376aede1ba
commit 3ad1d91c68
3 changed files with 7 additions and 7 deletions

View File

@@ -30,6 +30,6 @@ interface MetadataInterface
* *
* @return bool `true` if the key is set (regardless of what the value is), otherwise `false`. * @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;
} }

View File

@@ -21,7 +21,7 @@ final class Metadata implements MetadataInterface
public function get(string $key): mixed public function get(string $key): mixed
{ {
if (!$this->has($key)) { if (!$this->isSet($key)) {
throw new MissingKeyException($key); throw new MissingKeyException($key);
} }
@@ -35,7 +35,7 @@ final class Metadata implements MetadataInterface
return $this; return $this;
} }
public function has(string $key): bool public function isSet(string $key): bool
{ {
return array_key_exists($key, $this->metadata); return array_key_exists($key, $this->metadata);
} }

View File

@@ -47,17 +47,17 @@ final class MetadataTest extends TestCase
$this->assertSame($valueB, $result); $this->assertSame($valueB, $result);
} }
public function testHasReturnsTrueWhenKeyIsSet(): void public function testIsSetReturnsTrueWhenKeyIsSet(): void
{ {
$key = 'null'; $key = 'null';
$this->metadata->set($key, null); $this->metadata->set($key, null);
$result = $this->metadata->has($key); $result = $this->metadata->isSet($key);
$this->assertTrue($result); $this->assertTrue($result);
} }
public function testHasReturnsFalseWhenKeyIsNotSet(): void public function testIsSetReturnsFalseWhenKeyIsNotSet(): void
{ {
$result = $this->metadata->has('missing'); $result = $this->metadata->isSet('missing');
$this->assertFalse($result); $this->assertFalse($result);
} }
} }