Code Duplication    Length = 24-25 lines in 2 locations

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

@@ 1160-1183 (lines=24) @@
1157
     * @param array $documents Array of documents to insert
1158
     * @param array $options Array of options to be used with batchInsert()
1159
     */
1160
    private function executeInserts(ClassMetadata $class, array $documents, array $options = array())
1161
    {
1162
        $persister = $this->getDocumentPersister($class->name);
1163
1164
        foreach ($documents as $oid => $document) {
1165
            $persister->addInsert($document);
1166
            unset($this->documentInsertions[$oid]);
1167
        }
1168
1169
        $persister->executeInserts($options);
1170
1171
        $hasPostPersistLifecycleCallbacks = ! empty($class->lifecycleCallbacks[Events::postPersist]);
1172
        $hasPostPersistListeners = $this->evm->hasListeners(Events::postPersist);
1173
1174
        foreach ($documents as $document) {
1175
            if ($hasPostPersistLifecycleCallbacks) {
1176
                $class->invokeLifecycleCallbacks(Events::postPersist, $document, array(new LifecycleEventArgs($document, $this->dm)));
1177
            }
1178
            if ($hasPostPersistListeners) {
1179
                $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($document, $this->dm));
1180
            }
1181
            $this->cascadePostPersist($class, $document);
1182
        }
1183
    }
1184
1185
    /**
1186
     * Executes all document upserts for documents of the specified type.
@@ 1192-1216 (lines=25) @@
1189
     * @param array $documents Array of documents to upsert
1190
     * @param array $options Array of options to be used with batchInsert()
1191
     */
1192
    private function executeUpserts(ClassMetadata $class, array $documents, array $options = array())
1193
    {
1194
        $persister = $this->getDocumentPersister($class->name);
1195
1196
1197
        foreach ($documents as $oid => $document) {
1198
            $persister->addUpsert($document);
1199
            unset($this->documentUpserts[$oid]);
1200
        }
1201
1202
        $persister->executeUpserts($options);
1203
1204
        $hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postPersist]);
1205
        $hasListeners = $this->evm->hasListeners(Events::postPersist);
1206
1207
        foreach ($documents as $document) {
1208
            if ($hasLifecycleCallbacks) {
1209
                $class->invokeLifecycleCallbacks(Events::postPersist, $document, array(new LifecycleEventArgs($document, $this->dm)));
1210
            }
1211
            if ($hasListeners) {
1212
                $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($document, $this->dm));
1213
            }
1214
            $this->cascadePostPersist($class, $document);
1215
        }
1216
    }
1217
1218
    /**
1219
     * Executes all document updates for documents of the specified type.