function AbstractMap::replace
Parameters
K $key The key to replace.:
T $value The value to set at `$key`.:
Return value
T | null the previous value associated with key, or `null` if there was no mapping for `$key`.
Overrides MapInterface::replace
File
-
vendor/
ramsey/ collection/ src/ Map/ AbstractMap.php, line 166
Class
- AbstractMap
- This class provides a basic implementation of `MapInterface`, to minimize the effort required to implement this interface.
Namespace
Ramsey\Collection\MapCode
public function replace(int|string $key, mixed $value) : mixed {
$currentValue = $this->get($key);
if ($this->containsKey($key)) {
$this[$key] = $value;
}
return $currentValue;
}