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

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