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
    }
@@ 1040-1042 (lines=3) @@
1037
    private function persistNew(ClassMetadata $class, $document)
1038
    {
1039
        $oid = spl_object_hash($document);
1040
        if ( ! empty($class->lifecycleCallbacks[Events::prePersist])) {
1041
            $class->invokeLifecycleCallbacks(Events::prePersist, $document, array(new LifecycleEventArgs($document, $this->dm)));
1042
        }
1043
        if ($this->evm->hasListeners(Events::prePersist)) {
1044
            $this->evm->dispatchEvent(Events::prePersist, new LifecycleEventArgs($document, $this->dm));
1045
        }
@@ 1120-1122 (lines=3) @@
1117
                    $embeddedClass = $this->dm->getClassMetadata(get_class($embeddedDocument));
1118
                }
1119
1120
                if ( ! empty($embeddedClass->lifecycleCallbacks[Events::postPersist])) {
1121
                    $embeddedClass->invokeLifecycleCallbacks(Events::postPersist, $embeddedDocument, array(new LifecycleEventArgs($document, $this->dm)));
1122
                }
1123
                if ($hasPostPersistListeners) {
1124
                    $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($embeddedDocument, $this->dm));
1125
                }
@@ 1335-1339 (lines=5) @@
1332
                }
1333
1334
                if (isset($this->documentInsertions[$entryOid])) {
1335
                    if ( ! empty($entryClass->lifecycleCallbacks[Events::postPersist])) {
1336
                        $entryClass->invokeLifecycleCallbacks(Events::postPersist, $entry, array(
1337
                            new LifecycleEventArgs($entry, $this->dm)
1338
                        ));
1339
                    }
1340
                    if ($hasPostPersistListeners) {
1341
                        $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($entry, $this->dm));
1342
                    }
@@ 1344-1348 (lines=5) @@
1341
                        $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($entry, $this->dm));
1342
                    }
1343
                } else {
1344
                    if ( ! empty($entryClass->lifecycleCallbacks[Events::postUpdate])) {
1345
                        $entryClass->invokeLifecycleCallbacks(Events::postUpdate, $entry, array(
1346
                            new LifecycleEventArgs($entry, $this->dm)
1347
                        ));
1348
                    }
1349
                    if ($hasPostUpdateListeners) {
1350
                        $this->evm->dispatchEvent(Events::postUpdate, new LifecycleEventArgs($entry, $this->dm));
1351
                    }
@@ 1940-1942 (lines=3) @@
1937
                // nothing to do
1938
                break;
1939
            case self::STATE_MANAGED:
1940
                if ( ! empty($class->lifecycleCallbacks[Events::preRemove])) {
1941
                    $class->invokeLifecycleCallbacks(Events::preRemove, $document, array(new LifecycleEventArgs($document, $this->dm)));
1942
                }
1943
                if ($this->evm->hasListeners(Events::preRemove)) {
1944
                    $this->evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($document, $this->dm));
1945
                }