/** * {@internal we use this to set the data array in Factory()}} * * @see Factory() * @param array $newsource */ private function _setSource(&$newsource) { $this->_source = Inspekt::convertArrayToArrayObject($newsource); // foreach ($newsource as $key => $value) { // if (is_array($value)) { // $value = new ArrayObject($value); // $newsource[$key] = $value; // $this->_setSource($newsource[$key]); // } // } // $this->_source = new ArrayObject($newsource); }
/** * {@internal we use this to set the data array in Factory()}} * * @see Factory() * @param array $newsource */ private function _setSource(&$newsource) { $this->_source = Inspekt::convertArrayToArrayObject($newsource); }
/** * Converts an array into an ArrayObject. We use ArrayObjects when walking arrays in Inspekt * @param array * @return ArrayObject * */ public static function convertArrayToArrayObject(&$arr) { foreach ($arr as $key => $value) { if (is_array($value)) { $value = new ArrayObject($value); $arr[$key] = $value; //echo $key." is an array\n"; Inspekt::convertArrayToArrayObject($arr[$key]); } } return new ArrayObject($arr); }
/** * */ public function testConvertArrayToArrayObject() { $arr = array(1, 2, 3, 4); $ao = Inspekt::convertArrayToArrayObject($arr); $this->assertTrue($ao instanceof ArrayObject); }