Code Duplication    Length = 18-18 lines in 2 locations

lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php 1 location

@@ 399-416 (lines=18) @@
396
        /* Add a discriminator value if the embedded document is not mapped
397
         * explicitly to a targetDocument class.
398
         */
399
        if ( ! isset($embeddedMapping['targetDocument'])) {
400
            $discriminatorField = $embeddedMapping['discriminatorField'];
401
            $discriminatorValue = isset($embeddedMapping['discriminatorMap'])
402
                ? array_search($class->name, $embeddedMapping['discriminatorMap'])
403
                : $class->name;
404
405
            /* If the discriminator value was not found in the map, use the full
406
             * class name. In the future, it may be preferable to throw an
407
             * exception here (perhaps based on some strictness option).
408
             *
409
             * @see DocumentManager::createDBRef()
410
             */
411
            if ($discriminatorValue === false) {
412
                $discriminatorValue = $class->name;
413
            }
414
415
            $embeddedDocumentValue[$discriminatorField] = $discriminatorValue;
416
        }
417
418
        /* If the class has a discriminator (field and value), use it. A child
419
         * class that is not defined in the discriminator map may only have a

lib/Doctrine/ODM/MongoDB/DocumentManager.php 1 location

@@ 721-738 (lines=18) @@
718
        /* Add a discriminator value if the referenced document is not mapped
719
         * explicitly to a targetDocument class.
720
         */
721
        if ($referenceMapping !== null && ! isset($referenceMapping['targetDocument'])) {
722
            $discriminatorField = $referenceMapping['discriminatorField'];
723
            $discriminatorValue = isset($referenceMapping['discriminatorMap'])
724
                ? array_search($class->name, $referenceMapping['discriminatorMap'])
725
                : $class->name;
726
727
            /* If the discriminator value was not found in the map, use the full
728
             * class name. In the future, it may be preferable to throw an
729
             * exception here (perhaps based on some strictness option).
730
             *
731
             * @see PersistenceBuilder::prepareEmbeddedDocumentValue()
732
             */
733
            if ($discriminatorValue === false) {
734
                $discriminatorValue = $class->name;
735
            }
736
737
            $dbRef[$discriminatorField] = $discriminatorValue;
738
        }
739
740
        return $dbRef;
741
    }