Prado\Collections\TMap::remove PHP Метод

remove() публичный Метод

Removes an item from the map by its key.
public remove ( $key ) : mixed
Результат mixed the removed value, null if no such key exists.
    public function remove($key)
    {
        if (!$this->_r) {
            if (isset($this->_d[$key]) || array_key_exists($key, $this->_d)) {
                $value = $this->_d[$key];
                unset($this->_d[$key]);
                return $value;
            } else {
                return null;
            }
        } else {
            throw new TInvalidOperationException('map_readonly', get_class($this));
        }
    }

Usage Example

Пример #1
0
 public function testCanNotRemoveWhenReadOnly()
 {
     $map = new TMap(array('key' => 'value'), true);
     try {
         $map->remove('key');
     } catch (TInvalidOperationException $e) {
         return;
     }
     self::fail('An expected TInvalidOperationException was not raised');
 }
All Usage Examples Of Prado\Collections\TMap::remove