Code Duplication    Length = 24-25 lines in 2 locations

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

@@ 1137-1160 (lines=24) @@
1134
     * @param array $documents Array of documents to insert
1135
     * @param array $options Array of options to be used with batchInsert()
1136
     */
1137
    private function executeInserts(ClassMetadata $class, array $documents, array $options = array())
1138
    {
1139
        $persister = $this->getDocumentPersister($class->name);
1140
1141
        foreach ($documents as $oid => $document) {
1142
            $persister->addInsert($document);
1143
            unset($this->documentInsertions[$oid]);
1144
        }
1145
1146
        $persister->executeInserts($options);
1147
1148
        $hasPostPersistLifecycleCallbacks = ! empty($class->lifecycleCallbacks[Events::postPersist]);
1149
        $hasPostPersistListeners = $this->evm->hasListeners(Events::postPersist);
1150
1151
        foreach ($documents as $document) {
1152
            if ($hasPostPersistLifecycleCallbacks) {
1153
                $class->invokeLifecycleCallbacks(Events::postPersist, $document, array(new LifecycleEventArgs($document, $this->dm)));
1154
            }
1155
            if ($hasPostPersistListeners) {
1156
                $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($document, $this->dm));
1157
            }
1158
            $this->cascadePostPersist($class, $document);
1159
        }
1160
    }
1161
1162
    /**
1163
     * Executes all document upserts for documents of the specified type.
@@ 1169-1193 (lines=25) @@
1166
     * @param array $documents Array of documents to upsert
1167
     * @param array $options Array of options to be used with batchInsert()
1168
     */
1169
    private function executeUpserts(ClassMetadata $class, array $documents, array $options = array())
1170
    {
1171
        $persister = $this->getDocumentPersister($class->name);
1172
1173
1174
        foreach ($documents as $oid => $document) {
1175
            $persister->addUpsert($document);
1176
            unset($this->documentUpserts[$oid]);
1177
        }
1178
1179
        $persister->executeUpserts($options);
1180
1181
        $hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postPersist]);
1182
        $hasListeners = $this->evm->hasListeners(Events::postPersist);
1183
1184
        foreach ($documents as $document) {
1185
            if ($hasLifecycleCallbacks) {
1186
                $class->invokeLifecycleCallbacks(Events::postPersist, $document, array(new LifecycleEventArgs($document, $this->dm)));
1187
            }
1188
            if ($hasListeners) {
1189
                $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($document, $this->dm));
1190
            }
1191
            $this->cascadePostPersist($class, $document);
1192
        }
1193
    }
1194
1195
    /**
1196
     * Executes all document updates for documents of the specified type.