Exemple #1
0
 public function get($key, $default = null, $deleteAfter = false)
 {
     $value = ArrayUtil::getIn($this->session, [$this->name, $this->cleanKey($key)], $default);
     if ($deleteAfter) {
         unset($this->session[$this->name][$this->cleanKey($key)]);
     }
     return $value;
 }
 public function populateWithArray($data = [], $dirty = false)
 {
     unset($data['__meta__']);
     if ($dirty) {
         foreach ($data as $field => $value) {
             if (!array_key_exists($field, $this->data) || ArrayUtil::getIn($this->data, [$field]) !== $value) {
                 $this->dirty[$field] = $value;
             }
         }
     } else {
         $this->data = array_merge($this->data, $data);
     }
     return $this;
 }
 /** @test */
 public function ifKeyDoesNotExistsReturnDefault()
 {
     $array = ['foo' => ['bar']];
     $this->assertEquals('boo', ArrayUtil::getIn($array, ['foo', 'bar', 'baz'], 'boo'));
 }
 private function getConfig()
 {
     $config = $this->config;
     $config['mongo'] = ['client' => ['host' => ArrayUtil::getIn($config, ['client', 'host'], 'mongodb://localhost:27017'), 'options' => ArrayUtil::getIn($config, ['client', 'options'], []), 'driver_options' => ArrayUtil::getIn($config, ['client', 'driver_options'], [])], 'database' => ['main' => ArrayUtil::getIn($config, ['database', 'main'], 'maindb')]];
     return $config;
 }
 public function get($field, $default = null)
 {
     return ArrayUtil::getIn($this->params, [$field], $default);
 }