public function set($path, $value)
    {
        if (!empty($path)) {
            $at   = &$this->getValues();
            $keys = $this->explode($path);

            while (count($keys) > 0) {
                if (count($keys) === 1) {
                    if (is_array($at)) {
                        $at[array_shift($keys)] = $value;
                    } else {
                        throw new \RuntimeException("Can not set value at this path ($path) because is not array.");
                    }
                } else {
                    $key = array_shift($keys);
                    if (!isset($at[$key])) {
                        $at[$key] = [];
                    }
                    $at = &$at[$key];
                }
            }
        } else {
            $this->values = $value;
        }
    }
public function set($path, $value)
    {
        if (!empty($path)) {
            $at   = &$this->getValues();
            $keys = $this->explode($path);

            while (count($keys) > 0) {
                if (count($keys) === 1) {
                    if (is_array($at)) {
                        $at[array_shift($keys)] = $value;
                    } else {
                        throw new \RuntimeException("Can not set value at this path ($path) because is not array.");
                    }
                } else {
                    $key = array_shift($keys);
                    if (!isset($at[$key])) {
                        $at[$key] = [];
                    }
                    $at = &$at[$key];
                }
            }
        } else {
            $this->values = $value;
        }
    }
public function set ( $ path , $ value ) { if ( ! empty ( $ path ) ) { $ at = & $ this -> getValues ( ) ; $ keys = $ this -> explode ( $ path ) ; while ( count ( $ keys ) > 0 ) { if ( count ( $ keys ) === 1 ) { if ( is_array ( $ at ) ) { $ at [ array_shift ( $ keys ) ] = $ value ; } else { throw new \ RuntimeException ( "Can not set value at this path ($path) because is not array." ) ; } } else { $ key = array_shift ( $ keys ) ; if ( ! isset ( $ at [ $ key ] ) ) { $ at [ $ key ] = [ ] ; } $ at = & $ at [ $ key ] ; } } } else { $ this -> values = $ value ; } }
Sets a value for path.

@param string $path  Path to set value for.
@param mixed  $value Value to set

@author Anton Medvedev <anton (at) elfet (dot) ru>
Sets a value for path .