示例#1
0
 /**
  * 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;
 }
示例#2
0
文件: ListFinder.php 项目: titon/db
 /**
  * {@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;
 }
示例#3
0
文件: Locale.php 项目: titon/g11n
 /**
  * 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);
 }
示例#4
0
 function array_get(array $set, $path = null)
 {
     return Hash::get($set, $path);
 }
示例#5
0
 /**
  * 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;
 }
示例#6
0
 /**
  * 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'));
 }