Code Duplication    Length = 8-10 lines in 4 locations

lib/Doctrine/ODM/MongoDB/SchemaManager.php 4 locations

@@ 297-304 (lines=8) @@
294
     * @param string $documentName
295
     * @throws \InvalidArgumentException
296
     */
297
    public function deleteDocumentIndexes($documentName)
298
    {
299
        $class = $this->dm->getClassMetadata($documentName);
300
        if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
301
            throw new \InvalidArgumentException('Cannot delete document indexes for mapped super classes or embedded documents.');
302
        }
303
        $this->dm->getDocumentCollection($documentName)->deleteIndexes();
304
    }
305
306
    /**
307
     * Create all the mapped document collections in the metadata factory.
@@ 367-376 (lines=10) @@
364
     * @param string $documentName
365
     * @throws \InvalidArgumentException
366
     */
367
    public function dropDocumentCollection($documentName)
368
    {
369
        $class = $this->dm->getClassMetadata($documentName);
370
        if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
371
            throw new \InvalidArgumentException('Cannot delete document indexes for mapped super classes or embedded documents.');
372
        }
373
        $this->dm->getDocumentDatabase($documentName)->dropCollection(
374
            $class->getCollection()
375
        );
376
    }
377
378
    /**
379
     * Drop all the mapped document databases in the metadata factory.
@@ 397-404 (lines=8) @@
394
     * @param string $documentName
395
     * @throws \InvalidArgumentException
396
     */
397
    public function dropDocumentDatabase($documentName)
398
    {
399
        $class = $this->dm->getClassMetadata($documentName);
400
        if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
401
            throw new \InvalidArgumentException('Cannot drop document database for mapped super classes or embedded documents.');
402
        }
403
        $this->dm->getDocumentDatabase($documentName)->drop();
404
    }
405
406
    /**
407
     * Create all the mapped document databases in the metadata factory.
@@ 425-432 (lines=8) @@
422
     * @param string $documentName
423
     * @throws \InvalidArgumentException
424
     */
425
    public function createDocumentDatabase($documentName)
426
    {
427
        $class = $this->dm->getClassMetadata($documentName);
428
        if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
429
            throw new \InvalidArgumentException('Cannot delete document indexes for mapped super classes or embedded documents.');
430
        }
431
        $this->dm->getDocumentDatabase($documentName)->execute('function() { return true; }');
432
    }
433
434
    /**
435
     * Determine if an index returned by MongoCollection::getIndexInfo() can be