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
        }
@@ 290-301 (lines=12) @@
287
            $data = $this->pb->prepareUpsertData($document);
288
289
            // Set the initial version for each upsert
290
            if ($this->class->isVersioned) {
291
                $versionMapping = $this->class->fieldMappings[$this->class->versionField];
292
                if ($versionMapping['type'] === 'int') {
293
                    $nextVersion = max(1, (int) $this->class->reflFields[$this->class->versionField]->getValue($document));
294
                    $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersion);
295
                } elseif ($versionMapping['type'] === 'date') {
296
                    $nextVersionDateTime = new \DateTime();
297
                    $nextVersion = new \MongoDate($nextVersionDateTime->getTimestamp());
298
                    $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersionDateTime);
299
                }
300
                $data['$set'][$versionMapping['name']] = $nextVersion;
301
            }
302
303
            try {
304
                $this->executeUpsert($data, $options);