Code Duplication    Length = 12-12 lines in 2 locations

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

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