Exemple #1
0
 public function testSet()
 {
     $arr = new DotArray(['foo' => 'foo string!', 'bar' => ['bar1' => 'bar1 string!', 'bar2' => 'bar2 string!']]);
     $arr->set('foo', 'foo string!!');
     $this->assertSame('foo string!!', $arr->get('foo'));
     $arr->set('foo.bar', 'foo.bar string!');
     $this->assertSame(['bar' => 'foo.bar string!'], $arr->get('foo'));
     $arr->set('bar.bar2', 'bar2 string!!');
     $arr->set('bar.bar3', 'bar3 string!');
     $this->assertSame(['bar1' => 'bar1 string!', 'bar2' => 'bar2 string!!', 'bar3' => 'bar3 string!'], $arr->get('bar'));
     $arr->set('baz', 'baz string!');
     $this->assertSame(['foo' => ['bar' => 'foo.bar string!'], 'bar' => ['bar1' => 'bar1 string!', 'bar2' => 'bar2 string!!', 'bar3' => 'bar3 string!'], 'baz' => 'baz string!'], $arr->getRawData());
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function set($name, $value)
 {
     if ($this->readOnly) {
         throw new NotAllowedMethodException(__FUNCTION__, __CLASS__);
     }
     return parent::set($name, $value);
 }