convertArrayToArrayObject() public static method

Converts an array into an ArrayObject. We use ArrayObjects when walking arrays in Inspekt
public static convertArrayToArrayObject ( &$arr ) : ArrayObject
return ArrayObject
Ejemplo n.º 1
0
 /**
  * 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;
             Inspekt::convertArrayToArrayObject($arr[$key]);
         }
     }
     return new ArrayObject($arr);
 }
Ejemplo n.º 2
0
 /**
  *
  */
 public function testConvertArrayToArrayObject()
 {
     $arr = array(1, 2, 3, 4);
     $ao = Inspekt::convertArrayToArrayObject($arr);
     $this->assertTrue($ao instanceof \ArrayObject);
 }