Code Duplication    Length = 3-5 lines in 8 locations

lib/Doctrine/ODM/MongoDB/Tools/DocumentGenerator.php 8 locations

@@ 650-654 (lines=5) @@
647
648
        foreach ($metadata->fieldMappings as $fieldMapping) {
649
            if (isset($fieldMapping['id'])) {
650
                if ($metadata->generatorType == ClassMetadataInfo::GENERATOR_TYPE_NONE) {
651
                    if ($code = $this->generateDocumentStubMethod($metadata, 'set', $fieldMapping['fieldName'], $fieldMapping['type'])) {
652
                        $methods[] = $code;
653
                    }
654
                }
655
                if ($code = $code = $this->generateDocumentStubMethod($metadata, 'get', $fieldMapping['fieldName'], $fieldMapping['type'])) {
656
                    $methods[] = $code;
657
                }
@@ 655-657 (lines=3) @@
652
                        $methods[] = $code;
653
                    }
654
                }
655
                if ($code = $code = $this->generateDocumentStubMethod($metadata, 'get', $fieldMapping['fieldName'], $fieldMapping['type'])) {
656
                    $methods[] = $code;
657
                }
658
            } elseif ( ! isset($fieldMapping['association'])) {
659
                if ($code = $code = $this->generateDocumentStubMethod($metadata, 'set', $fieldMapping['fieldName'], $fieldMapping['type'])) {
660
                    $methods[] = $code;
@@ 659-661 (lines=3) @@
656
                    $methods[] = $code;
657
                }
658
            } elseif ( ! isset($fieldMapping['association'])) {
659
                if ($code = $code = $this->generateDocumentStubMethod($metadata, 'set', $fieldMapping['fieldName'], $fieldMapping['type'])) {
660
                    $methods[] = $code;
661
                }
662
                if ($code = $code = $this->generateDocumentStubMethod($metadata, 'get', $fieldMapping['fieldName'], $fieldMapping['type'])) {
663
                    $methods[] = $code;
664
                }
@@ 662-664 (lines=3) @@
659
                if ($code = $code = $this->generateDocumentStubMethod($metadata, 'set', $fieldMapping['fieldName'], $fieldMapping['type'])) {
660
                    $methods[] = $code;
661
                }
662
                if ($code = $code = $this->generateDocumentStubMethod($metadata, 'get', $fieldMapping['fieldName'], $fieldMapping['type'])) {
663
                    $methods[] = $code;
664
                }
665
            } elseif ($fieldMapping['type'] === ClassMetadataInfo::ONE) {
666
                $nullable = $this->isAssociationNullable($fieldMapping) ? 'null' : null;
667
                if ($code = $this->generateDocumentStubMethod($metadata, 'set', $fieldMapping['fieldName'], $fieldMapping['targetDocument'] ?? null, $nullable)) {
@@ 667-669 (lines=3) @@
664
                }
665
            } elseif ($fieldMapping['type'] === ClassMetadataInfo::ONE) {
666
                $nullable = $this->isAssociationNullable($fieldMapping) ? 'null' : null;
667
                if ($code = $this->generateDocumentStubMethod($metadata, 'set', $fieldMapping['fieldName'], $fieldMapping['targetDocument'] ?? null, $nullable)) {
668
                    $methods[] = $code;
669
                }
670
                if ($code = $this->generateDocumentStubMethod($metadata, 'get', $fieldMapping['fieldName'], $fieldMapping['targetDocument'] ?? null)) {
671
                    $methods[] = $code;
672
                }
@@ 670-672 (lines=3) @@
667
                if ($code = $this->generateDocumentStubMethod($metadata, 'set', $fieldMapping['fieldName'], $fieldMapping['targetDocument'] ?? null, $nullable)) {
668
                    $methods[] = $code;
669
                }
670
                if ($code = $this->generateDocumentStubMethod($metadata, 'get', $fieldMapping['fieldName'], $fieldMapping['targetDocument'] ?? null)) {
671
                    $methods[] = $code;
672
                }
673
            } elseif ($fieldMapping['type'] === ClassMetadataInfo::MANY) {
674
                if ($code = $this->generateDocumentStubMethod($metadata, 'add', $fieldMapping['fieldName'], $fieldMapping['targetDocument'] ?? null)) {
675
                    $methods[] = $code;
@@ 674-676 (lines=3) @@
671
                    $methods[] = $code;
672
                }
673
            } elseif ($fieldMapping['type'] === ClassMetadataInfo::MANY) {
674
                if ($code = $this->generateDocumentStubMethod($metadata, 'add', $fieldMapping['fieldName'], $fieldMapping['targetDocument'] ?? null)) {
675
                    $methods[] = $code;
676
                }
677
                if ($code = $this->generateDocumentStubMethod($metadata, 'remove', $fieldMapping['fieldName'], $fieldMapping['targetDocument'] ?? null)) {
678
                    $methods[] = $code;
679
                }
@@ 677-679 (lines=3) @@
674
                if ($code = $this->generateDocumentStubMethod($metadata, 'add', $fieldMapping['fieldName'], $fieldMapping['targetDocument'] ?? null)) {
675
                    $methods[] = $code;
676
                }
677
                if ($code = $this->generateDocumentStubMethod($metadata, 'remove', $fieldMapping['fieldName'], $fieldMapping['targetDocument'] ?? null)) {
678
                    $methods[] = $code;
679
                }
680
                if ($code = $this->generateDocumentStubMethod($metadata, 'get', $fieldMapping['fieldName'], '\Doctrine\Common\Collections\Collection')) {
681
                    $methods[] = $code;
682
                }