public function testIsTraversableObject() { $object = new \stdClass(); $this->assertFalse(Utils::isTraversable($object)); $object = new IteratorAggregate(); $this->assertTrue(Utils::isTraversable($object)); }
/** * 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; }