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 = new \MongoDate($nextVersionDateTime->getTimestamp());
234
                    $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersionDateTime);
235
                }
236
                $data[$versionMapping['name']] = $nextVersion;
237
            }
238
239
            $inserts[$oid] = $data;
240
        }
@@ 281-292 (lines=12) @@
278
            $data = $this->pb->prepareUpsertData($document);
279
280
            // Set the initial version for each upsert
281
            if ($this->class->isVersioned) {
282
                $versionMapping = $this->class->fieldMappings[$this->class->versionField];
283
                if ($versionMapping['type'] === 'int') {
284
                    $nextVersion = max(1, (int) $this->class->reflFields[$this->class->versionField]->getValue($document));
285
                    $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersion);
286
                } elseif ($versionMapping['type'] === 'date') {
287
                    $nextVersionDateTime = new \DateTime();
288
                    $nextVersion = new \MongoDate($nextVersionDateTime->getTimestamp());
289
                    $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersionDateTime);
290
                }
291
                $data['$set'][$versionMapping['name']] = $nextVersion;
292
            }
293
            
294
            try {
295
                $this->executeUpsert($data, $options);