| @@ 102-111 (lines=10) @@ | ||
| 99 | * @param mixed $key |
|
| 100 | * @return mixed|null |
|
| 101 | */ |
|
| 102 | public function removeKey($key) |
|
| 103 | { |
|
| 104 | if (!$this->hasKey($key)) { |
|
| 105 | return null; |
|
| 106 | } |
|
| 107 | unset($this->valueToKey[$this->keyToValue[$key]]); |
|
| 108 | $value = $this->keyToValue[$key]; |
|
| 109 | unset($this->keyToValue[$key]); |
|
| 110 | return $value; |
|
| 111 | } |
|
| 112 | ||
| 113 | /** |
|
| 114 | * Remove supplied value from map and return matching key. |
|
| @@ 118-127 (lines=10) @@ | ||
| 115 | * @param mixed $value |
|
| 116 | * @return mixed|null |
|
| 117 | */ |
|
| 118 | public function removeValue($value) |
|
| 119 | { |
|
| 120 | if (!$this->hasValue($value)) { |
|
| 121 | return null; |
|
| 122 | } |
|
| 123 | unset($this->keyToValue[$this->valueToKey[$value]]); |
|
| 124 | $key = $this->valueToKey[$value]; |
|
| 125 | unset($this->valueToKey[$value]); |
|
| 126 | return $key; |
|
| 127 | } |
|
| 128 | } |
|
| 129 | ||