/** * Grab a value from the current configuration. * * @param string $key * @param mixed $default * @return mixed */ public static function get($key, $default = null) { $value = Hash::get(static::$_config, $key); if ($value === null) { return $default; } return $value; }
/** * {@inheritdoc} */ public function after(array $results, array $options = []) { $key = isset($options['key']) ? $options['key'] : null; $value = isset($options['value']) ? $options['value'] : null; $list = []; if (!$key || !$value) { throw new InvalidArgumentException('Missing key or value option for ListFinder'); } foreach ($results as $result) { if ($result instanceof Entity) { $result = $result->toArray(); } $list[Hash::get($result, $key)] = Hash::get($result, $value); } return $list; }
/** * Return the validation rules from the locale bundle. * * @uses Titon\Utility\Hash * * @param string $key * @return string|array */ public function getValidationRules($key = null) { return Hash::get($this->_loadResource('validations'), $key); }
function array_get(array $set, $path = null) { return Hash::get($set, $path); }
/** * Return a parameter by key. * * @uses Titon\Utility\Hash * * @param string $key * @param mixed $default * @return mixed */ public function get($key, $default = null) { if (strpos($key, '.') === false) { $value = isset($this->_data[$key]) ? $this->_data[$key] : null; } else { $value = Hash::get($this->_data, $key); } if ($value === null) { return $default; } return $value; }
/** * Test that get() returns the full set, or the set value based on the dot notated path. */ public function testGet() { $data = $this->expanded; $this->assertEquals($data, Hash::get($data)); $this->assertEquals(true, Hash::get($data, 'boolean')); $this->assertEquals($data['one']['two']['three'], Hash::get($data, 'one.two.three')); $this->assertEquals($data['one']['two']['three']['four']['five']['six'], Hash::get($data, 'one.two.three.four.five.six')); }