Skip to content

Commit dbd2fea

Browse files
committed
Use is_iterable instead of multiple checks
1 parent 7f3d131 commit dbd2fea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Transformer/ModelToElasticaAutoTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function transform(object $object, array $fields): Document
8383
*/
8484
protected function transformNested($objects, array $fields)
8585
{
86-
if (\is_array($objects) || $objects instanceof \Traversable || $objects instanceof \ArrayAccess) {
86+
if (\is_iterable($objects)) {
8787
$documents = [];
8888
foreach ($objects as $object) {
8989
$document = $this->transformObjectToDocument($object, $fields);
@@ -117,7 +117,7 @@ protected function normalizeValue($value)
117117
}
118118
};
119119

120-
if (\is_array($value) || $value instanceof \Traversable || $value instanceof \ArrayAccess) {
120+
if (\is_iterable($value)) {
121121
$value = \is_array($value) ? $value : \iterator_to_array($value, false);
122122
\array_walk_recursive($value, $normalizeValue);
123123
} else {

0 commit comments

Comments
 (0)