function array_set(array $set, $path, $value) { return Hash::set($set, $path, $value); }
/** * Set a parameter value by key. * * @uses Titon\Utility\Hash * * @param string $key * @param mixed $value * @return $this */ public function set($key, $value = null) { if (strpos($key, '.') === false) { $this->_data[$key] = $value; } else { $this->_data = Hash::set($this->_data, $key, $value); } return $this; }
/** * Add values to the current loaded configuration. * * @uses Titon\Utility\Hash * * @param string $key * @param mixed $value */ public static function set($key, $value) { static::$_config = Hash::set(static::$_config, $key, $value); }
/** * Test that set() inserts data into the set based on the dot notated path; an array can also be passed. */ public function testSet() { $data = $this->expanded; $match = $data; $data = Hash::set($data, 'key', 'value'); $match['key'] = 'value'; $this->assertEquals($match, $data); $data = Hash::set($data, 'key.key', 'value'); $match['key'] = array('key' => 'value'); $this->assertEquals($match, $data); $data = Hash::set($data, array('key.key.key' => 'value', 'true' => true, 'one.false' => false)); $match['key']['key'] = array('key' => 'value'); $match['true'] = true; $match['one']['false'] = false; $this->assertEquals($match, $data); }