Ejemplo n.º 1
0
 public function testArrayGet()
 {
     $arr['one']['two']['three'] = 'foo';
     $this->assertEquals(false, func\array_get($arr, 'four'));
     $this->assertEquals('whatever', func\array_get($arr, 'four', 'whatever'));
     $this->assertEquals('foo', func\array_get($arr, 'one.two.three'));
     $this->assertEquals(false, func\array_get($arr, 'one.two.whatever'));
     $this->assertEquals(['two' => ['three' => 'foo']], func\array_get($arr, 'one'));
 }
Ejemplo n.º 2
0
 /**
  * Retrieves the config value for the given key and returns an optional default value.
  *
  * @param string $key     a config key, use dot.notation.for.sub.array.keys
  * @param mixed  $default [optional] a default value to return, defaults to false
  *
  * @return mixed the desired value
  */
 public function config(string $key, $default = false)
 {
     return func\array_get($this->config, $key, $default);
 }