More type stuff and unused code removed.

This commit is contained in:
2023-08-01 12:56:37 +00:00
parent dc35035c3c
commit 7792552c9f
9 changed files with 20 additions and 44 deletions

View File

@ -11,14 +11,14 @@ class HashMap
private array $_hashToKey = [];
public function getValue($key)
public function getValue(string|object $key): mixed
{
$hash = self::getHash($key);
return $this->_hashToValue[$hash];
}
public function setValue($key, $value)
public function setValue(string|object $key, mixed $value): self
{
$hash = self::getHash($key);
$this->_hashToKey[$hash] = $key;
@ -27,22 +27,22 @@ class HashMap
return $this;
}
public function getAllKeys()
public function getAllKeys(): array
{
return array_values($this->_hashToKey);
}
public function getAllValues()
public function getAllValues(): array
{
return array_values($this->_hashToValue);
}
public function count()
public function count(): int
{
return count($this->_hashToKey);
}
private static function getHash($key)
private static function getHash(string|Object $key): string
{
if (is_object($key)) {
return spl_object_hash($key);