| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 55 | 
| Lines | 55 | 
| Ratio | 100 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 96 | View Code Duplication | public function testParentUserGroupLimitationForbid()  | 
            |
| 97 |     { | 
            ||
| 98 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\UnauthorizedException::class);  | 
            ||
| 99 | |||
| 100 | $repository = $this->getRepository();  | 
            ||
| 101 | $userService = $repository->getUserService();  | 
            ||
| 102 | $permissionResolver = $repository->getPermissionResolver();  | 
            ||
| 103 | |||
| 104 |         $parentUserGroupId = $this->generateId('location', 4); | 
            ||
| 105 | /* BEGIN: Use Case */  | 
            ||
| 106 | $user = $this->createUserVersion1();  | 
            ||
| 107 | |||
| 108 |         $userGroupCreate = $userService->newUserGroupCreateStruct('eng-GB'); | 
            ||
| 109 |         $userGroupCreate->setField('name', 'Shared wiki'); | 
            ||
| 110 | |||
| 111 | $userGroup = $userService->createUserGroup(  | 
            ||
| 112 | $userGroupCreate,  | 
            ||
| 113 | $userService->loadUserGroup(  | 
            ||
| 114 | $parentUserGroupId  | 
            ||
| 115 | )  | 
            ||
| 116 | );  | 
            ||
| 117 | |||
| 118 | // Assign only example user to new group  | 
            ||
| 119 | $userService->assignUserToUserGroup($user, $userGroup);  | 
            ||
| 120 | |||
| 121 | $roleService = $repository->getRoleService();  | 
            ||
| 122 | |||
| 123 |         $policyCreate = $roleService->newPolicyCreateStruct('content', 'create'); | 
            ||
| 124 | $policyCreate->addLimitation(  | 
            ||
| 125 | new ParentUserGroupLimitation(  | 
            ||
| 126 | [  | 
            ||
| 127 | 'limitationValues' => [true],  | 
            ||
| 128 | ]  | 
            ||
| 129 | )  | 
            ||
| 130 | );  | 
            ||
| 131 | |||
| 132 |         $role = $roleService->loadRoleByIdentifier('Editor'); | 
            ||
| 133 | $roleDraft = $roleService->createRoleDraft($role);  | 
            ||
| 134 | $roleService->addPolicyByRoleDraft(  | 
            ||
| 135 | $roleDraft,  | 
            ||
| 136 | $policyCreate  | 
            ||
| 137 | );  | 
            ||
| 138 | $roleService->addPolicyByRoleDraft(  | 
            ||
| 139 | $roleDraft,  | 
            ||
| 140 |             $roleService->newPolicyCreateStruct('content', 'read') | 
            ||
| 141 | );  | 
            ||
| 142 | $roleService->publishRoleDraft($roleDraft);  | 
            ||
| 143 | |||
| 144 | $roleService->assignRoleToUserGroup($role, $userGroup);  | 
            ||
| 145 | |||
| 146 | $permissionResolver->setCurrentUserReference($user);  | 
            ||
| 147 | |||
| 148 | $this->createWikiPageDraft();  | 
            ||
| 149 | /* END: Use Case */  | 
            ||
| 150 | }  | 
            ||
| 151 | }  | 
            ||
| 152 |