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

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

Note, if the specified key already exists, the old value will be overwritten.
public add ( $key, $value )
    public function add($key, $value)
    {
        if (!$this->_r) {
            $this->_d[$key] = $value;
        } else {
            throw new TInvalidOperationException('map_readonly', get_class($this));
        }
    }

Usage Example

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