Code Duplication    Length = 16-22 lines in 2 locations

Core/Executor/RoleManager.php 2 locations

@@ 323-338 (lines=16) @@
320
    {
321
        foreach ($assignments as $assign) {
322
            switch ($assign['type']) {
323
                case 'user':
324
                    foreach ($assign['ids'] as $userId) {
325
                        $userId = $this->referenceResolver->resolveReference($userId);
326
327
                        $user = $userService->loadUser($userId);
328
329
                        if (!isset($assign['limitations'])) {
330
                            $roleService->assignRoleToUser($role, $user);
331
                        } else {
332
                            foreach ($assign['limitations'] as $limitation) {
333
                                $limitationObject = $this->createLimitation($roleService, $limitation);
334
                                $roleService->assignRoleToUser($role, $user, $limitationObject);
335
                            }
336
                        }
337
                    }
338
                    break;
339
                case 'group':
340
                    foreach ($assign['ids'] as $groupId) {
341
                        $groupId = $this->referenceResolver->resolveReference($groupId);
@@ 339-360 (lines=22) @@
336
                        }
337
                    }
338
                    break;
339
                case 'group':
340
                    foreach ($assign['ids'] as $groupId) {
341
                        $groupId = $this->referenceResolver->resolveReference($groupId);
342
343
                        $group = $userService->loadUserGroup($groupId);
344
345
                        if (!isset($assign['limitations'])) {
346
                            // q: why are we swallowing exceptions here ?
347
                            //try {
348
                                $roleService->assignRoleToUserGroup($role, $group);
349
                            //} catch (InvalidArgumentException $e) {}
350
                        } else {
351
                            foreach ($assign['limitations'] as $limitation) {
352
                                $limitationObject = $this->createLimitation($roleService, $limitation);
353
                                // q: why are we swallowing exceptions here ?
354
                                //try {
355
                                    $roleService->assignRoleToUserGroup($role, $group, $limitationObject);
356
                                //} catch (InvalidArgumentException $e) {}
357
                            }
358
                        }
359
                    }
360
                    break;
361
            }
362
        }
363
    }