/** * set data to the object. * * @param string $key * @param mixed $value * @param mixed $param * * @return void */ public function set($key, $value, $param = null) { CCArr::set($key, $value, $this->_data); }
/** * test the CCArr setter */ public function testArraySetItem() { $test_array = $this->test_array; /* * set string */ CCArr::set('string', 'batz', $test_array); $this->assertEquals(CCArr::get('string', $test_array), 'batz'); /* * set number */ CCArr::set('array.number', 0, $test_array); $this->assertEquals(CCArr::get('array.number', $test_array), 0); /* * set new value */ CCArr::set('not.existing.item', 'new value', $test_array); $this->assertEquals(CCArr::get('not.existing.item', $test_array), 'new value'); /* * set value in deep field */ CCArr::set('not.existing.item.in.deep.deep.field', 'deep', $test_array); $this->assertEquals(CCArr::get('not.existing.item.in.deep.deep.field', $test_array), 'deep'); }
/** * custom setter with encode ability * * @param string $key * @param mixed $value * @param mixed $param * @return void */ public function set($key, $value, $param = null) { if ($param === true) { $value = CCStr::htmlentities($value); } return CCArr::set($key, $value, $this->_data); }