diff --git a/src/HashMap.php b/src/HashMap.php index d1cde2e..62ca46a 100644 --- a/src/HashMap.php +++ b/src/HashMap.php @@ -19,16 +19,16 @@ class HashMap */ private array $hashToKey = []; - public function getValue(string|object $key): mixed + public function getValue(object $key): object { - $hash = self::getHash($key); + $hash = spl_object_id($key); return $this->hashToValue[$hash]; } - public function setValue(string|object $key, mixed $value): self + public function setValue(object $key, mixed $value): self { - $hash = self::getHash($key); + $hash = spl_object_id($key); $this->hashToKey[$hash] = $key; $this->hashToValue[$hash] = $value; @@ -55,13 +55,4 @@ class HashMap { return count($this->hashToKey); } - - private static function getHash(string|object $key): string - { - if (is_object($key)) { - return spl_object_hash($key); - } - - return $key; - } }