src/Jimphle/DataStructure/Map.php
public function setIn($keys, $value)
    {
        $lastKey = array_shift($keys);
        if (count($keys) > 0 && !isset($this->$lastKey->{$keys[0]})) {
            throw new \RuntimeException(sprintf("Key '%s->%s' does not exist.", $lastKey, $keys[0]));
        }
        if (count($keys) > 0 && $this->$lastKey instanceof Map) {
            return $this->merge(new self(array($lastKey => $this->$lastKey->setIn($keys, $value))));
        }
        return $this->merge(new self(array($lastKey => $value)));
    }
public function setIn($keys, $value)
    {
        $lastKey = array_shift($keys);
        if (count($keys) > 0 && !isset($this->$lastKey->{$keys[0]})) {
            throw new \RuntimeException(sprintf("Key '%s->%s' does not exist.", $lastKey, $keys[0]));
        }
        if (count($keys) > 0 && $this->$lastKey instanceof Map) {
            return $this->merge(new self(array($lastKey => $this->$lastKey->setIn($keys, $value))));
        }
        return $this->merge(new self(array($lastKey => $value)));
    }
public function setIn ( $ keys , $ value ) { $ lastKey = array_shift ( $ keys ) ; if ( count ( $ keys ) > 0 && ! isset ( $ this -> $ lastKey -> { $ keys [ 0 ] } ) ) { throw new \ RuntimeException ( sprintf ( "Key '%s->%s' does not exist." , $ lastKey , $ keys [ 0 ] ) ) ; } if ( count ( $ keys ) > 0 && $ this -> $ lastKey instanceof Map ) { return $ this -> merge ( new self ( array ( $ lastKey => $ this -> $ lastKey -> setIn ( $ keys , $ value ) ) ) ) ; } return $ this -> merge ( new self ( array ( $ lastKey => $ value ) ) ) ; }
set a value in a nested map
@param array $keys
@param mixed $value
@return Map
set a value in a nested map