Code Duplication    Length = 8-8 lines in 2 locations

src/MongoDB.php 2 locations

@@ 87-94 (lines=8) @@
84
            $iterator = new \IteratorIterator($cursor);
85
            $iterator->rewind();
86
            $results=[];
87
            while ($doc = $iterator->current()) {
88
                if (isset($doc['_id'])) {
89
                    $doc['id'] = (string) $doc['_id'];
90
                    unset($doc['_id']);
91
                }
92
                $results[$doc['id']] = $doc;
93
                $iterator->next();
94
            }
95
            return $results;
96
        } else {
97
            $filter = ['_id' => new MongoDBLib\BSON\ObjectID($docId)];
@@ 182-189 (lines=8) @@
179
            $cursor = $collection->find($query_filters, $options);
180
            $iterator = new \IteratorIterator($cursor);
181
            $iterator->rewind();
182
            while ($doc = $iterator->current()) {
183
                if (isset($doc['_id'])) {
184
                    $doc['id'] = (string) $doc['_id'];
185
                    unset($doc['_id']);
186
                }
187
                $results[] = $doc;
188
                $iterator->next();
189
            }
190
            return ['total' => $count, 'data' => $results];
191
        }
192
        return ['total' => 0, 'data' => null];