Code Duplication    Length = 16-22 lines in 2 locations

Core/Executor/RoleManager.php 2 locations

@@ 255-270 (lines=16) @@
252
    {
253
        foreach ($assignments as $assign) {
254
            switch ($assign['type']) {
255
                case 'user':
256
                    foreach ($assign['ids'] as $userId) {
257
                        $userId = $this->referenceResolver->resolveReference($userId);
258
259
                        $user = $userService->loadUser($userId);
260
261
                        if (!isset($assign['limitations'])) {
262
                            $roleService->assignRoleToUser($role, $user);
263
                        } else {
264
                            foreach ($assign['limitations'] as $limitation) {
265
                                $limitationObject = $this->createLimitation($roleService, $limitation);
266
                                $roleService->assignRoleToUser($role, $user, $limitationObject);
267
                            }
268
                        }
269
                    }
270
                    break;
271
                case 'group':
272
                    foreach ($assign['ids'] as $groupId) {
273
                        $groupId = $this->referenceResolver->resolveReference($groupId);
@@ 271-292 (lines=22) @@
268
                        }
269
                    }
270
                    break;
271
                case 'group':
272
                    foreach ($assign['ids'] as $groupId) {
273
                        $groupId = $this->referenceResolver->resolveReference($groupId);
274
275
                        $group = $userService->loadUserGroup($groupId);
276
277
                        if (!isset($assign['limitations'])) {
278
                            // q: why are we swallowing exceptions here ?
279
                            //try {
280
                                $roleService->assignRoleToUserGroup($role, $group);
281
                            //} catch (InvalidArgumentException $e) {}
282
                        } else {
283
                            foreach ($assign['limitations'] as $limitation) {
284
                                $limitationObject = $this->createLimitation($roleService, $limitation);
285
                                // q: why are we swallowing exceptions here ?
286
                                //try {
287
                                    $roleService->assignRoleToUserGroup($role, $group, $limitationObject);
288
                                //} catch (InvalidArgumentException $e) {}
289
                            }
290
                        }
291
                    }
292
                    break;
293
            }
294
        }
295
    }