Code Duplication    Length = 27-27 lines in 2 locations

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

@@ 314-340 (lines=27) @@
311
     * @param PolicyDraft $policyDraft the policy to remove from the role
312
     * @return APIRoleDraft if the authenticated user is not allowed to remove a policy
313
     */
314
    public function removePolicyByRoleDraft(APIRoleDraft $roleDraft, PolicyDraft $policyDraft)
315
    {
316
        $values = $this->requestParser->parse('role', $roleDraft->id);
317
        $response = $this->client->request(
318
            'DELETE',
319
            $this->requestParser->generate(
320
                'policy',
321
                array(
322
                    'role' => $values['role'],
323
                    'policy' => $policyDraft->id,
324
                )
325
            ),
326
            new Message(
327
            // @todo: What media-type should we set here? Actually, it should be
328
            // all expected exceptions + none? Or is "PolicyDraft" correct,
329
            // since this is what is to be expected by the resource
330
            // identified by the URL?
331
                array('Accept' => $this->outputVisitor->getMediaType('PolicyDraft'))
332
            )
333
        );
334
335
        if (!empty($response->body)) {
336
            $this->inputDispatcher->parse($response);
337
        }
338
339
        return $this->loadRole($roleDraft->id);
340
    }
341
342
    /**
343
     * Updates the limitations of a policy. The module and function cannot be changed and
@@ 576-602 (lines=27) @@
573
     *
574
     * @return \eZ\Publish\API\Repository\Values\User\Role the updated role
575
     */
576
    public function removePolicy(APIRole $role, APIPolicy $policy)
577
    {
578
        $values = $this->requestParser->parse('role', $role->id);
579
        $response = $this->client->request(
580
            'DELETE',
581
            $this->requestParser->generate(
582
                'policy',
583
                array(
584
                    'role' => $values['role'],
585
                    'policy' => $policy->id,
586
                )
587
            ),
588
            new Message(
589
                // @todo: What media-type should we set here? Actually, it should be
590
                // all expected exceptions + none? Or is "Policy" correct,
591
                // since this is what is to be expected by the resource
592
                // identified by the URL?
593
                array('Accept' => $this->outputVisitor->getMediaType('Policy'))
594
            )
595
        );
596
597
        if (!empty($response->body)) {
598
            $this->inputDispatcher->parse($response);
599
        }
600
601
        return $this->loadRole($role->id);
602
    }
603
604
    /**
605
     * Deletes a policy.