Code Duplication    Length = 23-25 lines in 3 locations

eZ/Publish/Core/REST/Client/RoleService.php 2 locations

@@ 799-823 (lines=25) @@
796
    /**
797
     * @see \eZ\Publish\API\Repository\RoleService::getRoleAssignmentsForUser()
798
     */
799
    public function getRoleAssignmentsForUser(User $user, $inherited = false)
800
    {
801
        $response = $this->client->request(
802
            'GET',
803
            $this->requestParser->generate('userRoleAssignments'),
804
            new Message(
805
                array('Accept' => $this->outputVisitor->getMediaType('RoleAssignmentList'))
806
            )
807
        );
808
809
        $roleAssignments = $this->inputDispatcher->parse($response);
810
811
        $userRoleAssignments = array();
812
        foreach ($roleAssignments as $roleAssignment) {
813
            $userRoleAssignments[] = new UserRoleAssignment(
814
                array(
815
                    'limitation' => $roleAssignment->getRoleLimitation(),
816
                    'role' => $roleAssignment->getRole(),
817
                    'user' => $user,
818
                )
819
            );
820
        }
821
822
        return $userRoleAssignments;
823
    }
824
825
    /**
826
     * Returns the roles assigned to the given user group.
@@ 834-858 (lines=25) @@
831
     *
832
     * @return \eZ\Publish\API\Repository\Values\User\UserGroupRoleAssignment[]
833
     */
834
    public function getRoleAssignmentsForUserGroup(UserGroup $userGroup)
835
    {
836
        $response = $this->client->request(
837
            'GET',
838
            $this->requestParser->generate('groupRoleAssignments'),
839
            new Message(
840
                array('Accept' => $this->outputVisitor->getMediaType('RoleAssignmentList'))
841
            )
842
        );
843
844
        $roleAssignments = $this->inputDispatcher->parse($response);
845
846
        $userGroupRoleAssignments = array();
847
        foreach ($roleAssignments as $roleAssignment) {
848
            $userGroupRoleAssignments[] = new UserGroupRoleAssignment(
849
                array(
850
                    'limitation' => $roleAssignment->getRoleLimitation(),
851
                    'role' => $roleAssignment->getRole(),
852
                    'userGroup' => $userGroup,
853
                )
854
            );
855
        }
856
857
        return $userGroupRoleAssignments;
858
    }
859
860
    /**
861
     * Instantiates a role create class.

eZ/Publish/Core/REST/Client/TrashService.php 1 location

@@ 208-230 (lines=23) @@
205
     *
206
     * @return \eZ\Publish\API\Repository\Values\Content\Trash\SearchResult
207
     */
208
    public function findTrashItems(Query $query)
209
    {
210
        $response = $this->client->request(
211
            'GET',
212
            $this->requestParser->generate('trashItems'),
213
            new Message(
214
                array('Accept' => $this->outputVisitor->getMediaType('LocationList'))
215
            )
216
        );
217
218
        $locations = $this->inputDispatcher->parse($response);
219
220
        $trashItems = array();
221
        foreach ($locations as $location) {
222
            $trashItems[] = $this->buildTrashItem($location);
223
        }
224
225
226
        return new SearchResult([
227
            'items' => $trashItems,
228
            'totalCount' => count($trashItems),
229
        ]);
230
    }
231
232
    /**
233
     * Converts the Location value object to TrashItem value object.