Code Duplication    Length = 16-22 lines in 2 locations

Core/Executor/RoleManager.php 2 locations

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