Code Duplication    Length = 12-12 lines in 2 locations

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

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