Code Duplication    Length = 12-12 lines in 2 locations

lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php 2 locations

@@ 226-237 (lines=12) @@
223
            $data = $this->pb->prepareInsertData($document);
224
225
            // Set the initial version for each insert
226
            if ($this->class->isVersioned) {
227
                $versionMapping = $this->class->fieldMappings[$this->class->versionField];
228
                if ($versionMapping['type'] === 'int') {
229
                    $nextVersion = max(1, (int) $this->class->reflFields[$this->class->versionField]->getValue($document));
230
                    $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersion);
231
                } elseif ($versionMapping['type'] === 'date') {
232
                    $nextVersionDateTime = new \DateTime();
233
                    $nextVersion = Type::convertPHPToDatabaseValue($nextVersionDateTime);
234
                    $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersionDateTime);
235
                }
236
                $data[$versionMapping['name']] = $nextVersion;
237
            }
238
239
            $inserts[] = $data;
240
        }
@@ 304-315 (lines=12) @@
301
        $data = $this->pb->prepareUpsertData($document);
302
303
        // Set the initial version for each upsert
304
        if ($this->class->isVersioned) {
305
            $versionMapping = $this->class->fieldMappings[$this->class->versionField];
306
            if ($versionMapping['type'] === 'int') {
307
                $nextVersion = max(1, (int) $this->class->reflFields[$this->class->versionField]->getValue($document));
308
                $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersion);
309
            } elseif ($versionMapping['type'] === 'date') {
310
                $nextVersionDateTime = new \DateTime();
311
                $nextVersion = Type::convertPHPToDatabaseValue($nextVersionDateTime);
312
                $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersionDateTime);
313
            }
314
            $data['$set'][$versionMapping['name']] = $nextVersion;
315
        }
316
317
        foreach (array_keys($criteria) as $field) {
318
            unset($data['$set'][$field]);