Code Duplication    Length = 3-5 lines in 7 locations

lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php 1 location

@@ 460-462 (lines=3) @@
457
        }
458
459
        // Invoke the postLoad lifecycle callbacks and listeners
460
        if ( ! empty($metadata->lifecycleCallbacks[Events::postLoad])) {
461
            $metadata->invokeLifecycleCallbacks(Events::postLoad, $document, array(new LifecycleEventArgs($document, $this->dm)));
462
        }
463
        if ($this->evm->hasListeners(Events::postLoad)) {
464
            $this->evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($document, $this->dm));
465
        }

lib/Doctrine/ODM/MongoDB/UnitOfWork.php 6 locations

@@ 653-655 (lines=3) @@
650
        }
651
652
        // Fire PreFlush lifecycle callbacks
653
        if ( ! empty($class->lifecycleCallbacks[Events::preFlush])) {
654
            $class->invokeLifecycleCallbacks(Events::preFlush, $document, array(new Event\PreFlushEventArgs($this->dm)));
655
        }
656
657
        $this->computeOrRecomputeChangeSet($class, $document);
658
    }
@@ 1036-1038 (lines=3) @@
1033
    private function persistNew(ClassMetadata $class, $document)
1034
    {
1035
        $oid = spl_object_hash($document);
1036
        if ( ! empty($class->lifecycleCallbacks[Events::prePersist])) {
1037
            $class->invokeLifecycleCallbacks(Events::prePersist, $document, array(new LifecycleEventArgs($document, $this->dm)));
1038
        }
1039
        if ($this->evm->hasListeners(Events::prePersist)) {
1040
            $this->evm->dispatchEvent(Events::prePersist, new LifecycleEventArgs($document, $this->dm));
1041
        }
@@ 1116-1118 (lines=3) @@
1113
                    $embeddedClass = $this->dm->getClassMetadata(get_class($embeddedDocument));
1114
                }
1115
1116
                if ( ! empty($embeddedClass->lifecycleCallbacks[Events::postPersist])) {
1117
                    $embeddedClass->invokeLifecycleCallbacks(Events::postPersist, $embeddedDocument, array(new LifecycleEventArgs($document, $this->dm)));
1118
                }
1119
                if ($hasPostPersistListeners) {
1120
                    $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($embeddedDocument, $this->dm));
1121
                }
@@ 1331-1335 (lines=5) @@
1328
                }
1329
1330
                if (isset($this->documentInsertions[$entryOid])) {
1331
                    if ( ! empty($entryClass->lifecycleCallbacks[Events::postPersist])) {
1332
                        $entryClass->invokeLifecycleCallbacks(Events::postPersist, $entry, array(
1333
                            new LifecycleEventArgs($entry, $this->dm)
1334
                        ));
1335
                    }
1336
                    if ($hasPostPersistListeners) {
1337
                        $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($entry, $this->dm));
1338
                    }
@@ 1340-1344 (lines=5) @@
1337
                        $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($entry, $this->dm));
1338
                    }
1339
                } else {
1340
                    if ( ! empty($entryClass->lifecycleCallbacks[Events::postUpdate])) {
1341
                        $entryClass->invokeLifecycleCallbacks(Events::postUpdate, $entry, array(
1342
                            new LifecycleEventArgs($entry, $this->dm)
1343
                        ));
1344
                    }
1345
                    if ($hasPostUpdateListeners) {
1346
                        $this->evm->dispatchEvent(Events::postUpdate, new LifecycleEventArgs($entry, $this->dm));
1347
                    }
@@ 1936-1938 (lines=3) @@
1933
                // nothing to do
1934
                break;
1935
            case self::STATE_MANAGED:
1936
                if ( ! empty($class->lifecycleCallbacks[Events::preRemove])) {
1937
                    $class->invokeLifecycleCallbacks(Events::preRemove, $document, array(new LifecycleEventArgs($document, $this->dm)));
1938
                }
1939
                if ($this->evm->hasListeners(Events::preRemove)) {
1940
                    $this->evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($document, $this->dm));
1941
                }