Code Duplication    Length = 8-8 lines in 2 locations

src/MongoDB.php 2 locations

@@ 99-106 (lines=8) @@
96
        $iterator = new \IteratorIterator($cursor);
97
        $iterator->rewind();
98
        $results=[];
99
        while ($doc = $iterator->current()) {
100
            if (isset($doc['_id'])) {
101
                $doc['id'] = (string) $doc['_id'];
102
                unset($doc['_id']);
103
            }
104
            $results[$doc['id']] = $doc;
105
            $iterator->next();
106
        }
107
        return $results;
108
    }
109
@@ 190-197 (lines=8) @@
187
            $cursor = $collection->find($query_filters, $options);
188
            $iterator = new \IteratorIterator($cursor);
189
            $iterator->rewind();
190
            while ($doc = $iterator->current()) {
191
                if (isset($doc['_id'])) {
192
                    $doc['id'] = (string) $doc['_id'];
193
                    unset($doc['_id']);
194
                }
195
                $results[] = $doc;
196
                $iterator->next();
197
            }
198
            return ['total' => $count, 'data' => $results];
199
        }
200
        return ['total' => 0, 'data' => null];