Code Duplication    Length = 16-22 lines in 2 locations

Core/Executor/RoleManager.php 2 locations

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