Code Duplication    Length = 13-14 lines in 5 locations

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

@@ 587-599 (lines=13) @@
584
     *
585
     * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
586
     */
587
    public function loadContentTypeByIdentifier($identifier)
588
    {
589
        $response = $this->client->request(
590
            'GET',
591
            $this->requestParser->generate('typeByIdentifier', array('type' => $identifier)),
592
            new Message(
593
                array('Accept' => $this->outputVisitor->getMediaType('ContentTypeList'))
594
            )
595
        );
596
        $contentTypes = $this->inputDispatcher->parse($response);
597
598
        return $this->completeContentType(reset($contentTypes));
599
    }
600
601
    /**
602
     * Get a Content Type object by id.
@@ 610-622 (lines=13) @@
607
     *
608
     * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
609
     */
610
    public function loadContentTypeByRemoteId($remoteId)
611
    {
612
        $response = $this->client->request(
613
            'GET',
614
            $this->requestParser->generate('typeByRemoteId', array('type' => $remoteId)),
615
            new Message(
616
                array('Accept' => $this->outputVisitor->getMediaType('ContentTypeList'))
617
            )
618
        );
619
        $contentTypes = $this->inputDispatcher->parse($response);
620
621
        return reset($contentTypes);
622
    }
623
624
    /**
625
     * Get Content Type objects which belong to the given content type group.

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

@@ 198-210 (lines=13) @@
195
     *
196
     * @return \eZ\Publish\API\Repository\Values\Content\Section
197
     */
198
    public function loadSectionByIdentifier($sectionIdentifier)
199
    {
200
        $response = $this->client->request(
201
            'GET',
202
            $this->requestParser->generate('sectionByIdentifier', array('section' => $sectionIdentifier)),
203
            new Message(
204
                array('Accept' => $this->outputVisitor->getMediaType('SectionList'))
205
            )
206
        );
207
        $result = $this->inputDispatcher->parse($response);
208
209
        return reset($result);
210
    }
211
212
    /**
213
     * Counts the contents which $section is assigned to.

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

@@ 707-720 (lines=14) @@
704
     *
705
     * @return \eZ\Publish\API\Repository\Values\User\Role
706
     */
707
    public function loadRoleByIdentifier($name)
708
    {
709
        $response = $this->client->request(
710
            'GET',
711
            $this->requestParser->generate('roleByIdentifier', array('role' => $name)),
712
            new Message(
713
                array('Accept' => $this->outputVisitor->getMediaType('RoleList'))
714
            )
715
        );
716
717
        $result = $this->inputDispatcher->parse($response);
718
719
        return reset($result);
720
    }
721
722
    /**
723
     * Loads all roles.
@@ 777-789 (lines=13) @@
774
     *
775
     * @return \eZ\Publish\API\Repository\Values\User\Policy[]
776
     */
777
    public function loadPoliciesByUserId($userId)
778
    {
779
        $values = $this->requestParser->parse('user', $userId);
780
        $response = $this->client->request(
781
            'GET',
782
            $this->requestParser->generate('userPolicies', array('user' => $values['user'])),
783
            new Message(
784
                array('Accept' => $this->outputVisitor->getMediaType('PolicyList'))
785
            )
786
        );
787
788
        return $this->inputDispatcher->parse($response);
789
    }
790
791
    /**
792
     * Assigns a role to the given user group.