Ejemplo n.º 1
0
 public function testIsTraversableObject()
 {
     $object = new \stdClass();
     $this->assertFalse(Utils::isTraversable($object));
     $object = new IteratorAggregate();
     $this->assertTrue(Utils::isTraversable($object));
 }
Ejemplo n.º 2
0
 /**
  * Recursively convert collection to array
  *
  * @param CollectionInterface|Traversable|array $collection
  *
  * @return array
  */
 protected static function convertToArray($collection)
 {
     $arr = [];
     foreach ($collection as $key => $value) {
         if (Utils::isTraversable($value)) {
             $arr[$key] = static::convertToArray($value);
         } else {
             $arr[$key] = $value;
         }
     }
     return $arr;
 }