Code Duplication    Length = 12-12 lines in 2 locations

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

@@ 243-254 (lines=12) @@
240
            $data = $this->pb->prepareInsertData($document);
241
242
            // Set the initial version for each insert
243
            if ($this->class->isVersioned) {
244
                $versionMapping = $this->class->fieldMappings[$this->class->versionField];
245
                if ($versionMapping['type'] === 'int') {
246
                    $nextVersion = max(1, (int) $this->class->reflFields[$this->class->versionField]->getValue($document));
247
                    $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersion);
248
                } elseif ($versionMapping['type'] === 'date') {
249
                    $nextVersionDateTime = new \DateTime();
250
                    $nextVersion = Type::convertPHPToDatabaseValue($nextVersionDateTime);
251
                    $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersionDateTime);
252
                }
253
                $data[$versionMapping['name']] = $nextVersion;
254
            }
255
256
            $inserts[] = $data;
257
        }
@@ 321-332 (lines=12) @@
318
        $data = $this->pb->prepareUpsertData($document);
319
320
        // Set the initial version for each upsert
321
        if ($this->class->isVersioned) {
322
            $versionMapping = $this->class->fieldMappings[$this->class->versionField];
323
            if ($versionMapping['type'] === 'int') {
324
                $nextVersion = max(1, (int) $this->class->reflFields[$this->class->versionField]->getValue($document));
325
                $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersion);
326
            } elseif ($versionMapping['type'] === 'date') {
327
                $nextVersionDateTime = new \DateTime();
328
                $nextVersion = Type::convertPHPToDatabaseValue($nextVersionDateTime);
329
                $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersionDateTime);
330
            }
331
            $data['$set'][$versionMapping['name']] = $nextVersion;
332
        }
333
334
        foreach (array_keys($criteria) as $field) {
335
            unset($data['$set'][$field]);