Code Duplication    Length = 8-8 lines in 2 locations

src/MongoDB.php 2 locations

@@ 100-107 (lines=8) @@
97
        $iterator = new \IteratorIterator($cursor);
98
        $iterator->rewind();
99
        $results=[];
100
        while ($doc = $iterator->current()) {
101
            if (isset($doc['_id'])) {
102
                $doc['id'] = (string) $doc['_id'];
103
                unset($doc['_id']);
104
            }
105
            $results[$doc['id']] = $doc;
106
            $iterator->next();
107
        }
108
        return $results;
109
    }
110
@@ 198-205 (lines=8) @@
195
            $cursor = $collection->find($query_filters, $options);
196
            $iterator = new \IteratorIterator($cursor);
197
            $iterator->rewind();
198
            while ($doc = $iterator->current()) {
199
                if (isset($doc['_id'])) {
200
                    $doc['id'] = (string) $doc['_id'];
201
                    unset($doc['_id']);
202
                }
203
                $results[] = $doc;
204
                $iterator->next();
205
            }
206
            return ['total' => $count, 'data' => $results];
207
        }
208
        return ['total' => 0, 'data' => null];