Code Duplication    Length = 7-10 lines in 5 locations

eZ/Publish/Core/REST/Server/Input/Parser/ContentUpdate.php 2 locations

@@ 41-47 (lines=7) @@
38
    {
39
        $parsedData = array();
40
41
        if (array_key_exists('Section', $data) && is_array($data['Section']) && isset($data['Section']['_href'])) {
42
            try {
43
                $parsedData['sectionId'] = $this->requestParser->parseHref($data['Section']['_href'], 'sectionId');
44
            } catch (Exceptions\InvalidArgumentException $e) {
45
                throw new Exceptions\Parser('Invalid format for <Section> reference in <ContentUpdate>.');
46
            }
47
        }
48
49
        if (array_key_exists('Owner', $data) && is_array($data['Owner']) && isset($data['Owner']['_href'])) {
50
            try {
@@ 49-55 (lines=7) @@
46
            }
47
        }
48
49
        if (array_key_exists('Owner', $data) && is_array($data['Owner']) && isset($data['Owner']['_href'])) {
50
            try {
51
                $parsedData['ownerId'] = $this->requestParser->parseHref($data['Owner']['_href'], 'userId');
52
            } catch (Exceptions\InvalidArgumentException $e) {
53
                throw new Exceptions\Parser('Invalid format for <Owner> reference in <ContentUpdate>.');
54
            }
55
        }
56
57
        if (array_key_exists('mainLanguageCode', $data)) {
58
            $parsedData['mainLanguageCode'] = $data['mainLanguageCode'];

eZ/Publish/Core/REST/Server/Input/Parser/UserGroupUpdate.php 1 location

@@ 87-93 (lines=7) @@
84
            $parsedData['mainLanguageCode'] = $data['mainLanguageCode'];
85
        }
86
87
        if (array_key_exists('Section', $data) && is_array($data['Section'])) {
88
            if (!array_key_exists('_href', $data['Section'])) {
89
                throw new Exceptions\Parser("Missing '_href' attribute for Section element in UserGroupUpdate.");
90
            }
91
92
            $parsedData['sectionId'] = $this->requestParser->parseHref($data['Section']['_href'], 'sectionId');
93
        }
94
95
        if (array_key_exists('remoteId', $data)) {
96
            $parsedData['remoteId'] = $data['remoteId'];

eZ/Publish/Core/REST/Server/Input/Parser/UserUpdate.php 1 location

@@ 101-107 (lines=7) @@
98
            $parsedData['mainLanguageCode'] = $data['mainLanguageCode'];
99
        }
100
101
        if (array_key_exists('Section', $data) && is_array($data['Section'])) {
102
            if (!array_key_exists('_href', $data['Section'])) {
103
                throw new Exceptions\Parser("Missing '_href' attribute for Section element in UserUpdate.");
104
            }
105
106
            $parsedData['sectionId'] = $this->requestParser->parseHref($data['Section']['_href'], 'sectionId');
107
        }
108
109
        if (array_key_exists('remoteId', $data)) {
110
            $parsedData['remoteId'] = $data['remoteId'];

eZ/Publish/Core/REST/Server/Input/Parser/RoleAssignInput.php 1 location

@@ 67-76 (lines=10) @@
64
65
        // @todo XSD says that limitation is mandatory, but roles can be assigned without limitations
66
        $limitation = null;
67
        if (array_key_exists('limitation', $data) && is_array($data['limitation'])) {
68
            if (!array_key_exists('_identifier', $data['limitation'])) {
69
                throw new Exceptions\Parser("Missing '_identifier' attribute for Limitation.");
70
            }
71
72
            $limitation = $parsingDispatcher->parse(
73
                $data['limitation'],
74
                'application/vnd.ez.api.internal.limitation.'  . $data['limitation']['_identifier']
75
            );
76
        }
77
78
        return new RoleAssignment($roleId, $limitation);
79
    }