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`.
|
* @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
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user