Code Duplication    Length = 27-30 lines in 2 locations

Core/Executor/SectionManager.php 1 location

@@ 127-153 (lines=27) @@
124
     * @throws \InvalidArgumentException When trying to assign a reference to an unsupported attribute
125
     * @return array key: the reference names, values: the reference values
126
     */
127
    protected function getReferencesValues($section, array $references, $step)
128
    {
129
        $refs = array();
130
131
        foreach ($references as $reference) {
132
            switch ($reference['attribute']) {
133
                case 'section_id':
134
                case 'id':
135
                    $value = $section->id;
136
                    break;
137
                case 'section_identifier':
138
                case 'identifier':
139
                    $value = $section->identifier;
140
                    break;
141
                case 'section_name':
142
                case 'name':
143
                    $value = $section->name;
144
                    break;
145
                default:
146
                    throw new \InvalidArgumentException('Section Manager does not support setting references for attribute ' . $reference['attribute']);
147
            }
148
149
            $refs[$reference['identifier']] = $value;
150
        }
151
152
        return $refs;
153
    }
154
155
    /**
156
     * @param array $matchCondition

Core/Executor/LanguageManager.php 1 location

@@ 117-146 (lines=30) @@
114
     * @throws \InvalidArgumentException When trying to assign a reference to an unsupported attribute
115
     * @return array key: the reference names, values: the reference values
116
     */
117
    protected function getReferencesValues($language, array $references, $step)
118
    {
119
        $refs = array();
120
121
        foreach ($references as $reference) {
122
123
            switch ($reference['attribute']) {
124
                case 'language_id':
125
                case 'id':
126
                    $value = $language->id;
127
                    break;
128
                case 'enabled':
129
                    $value = $language->enabled;
130
                    break;
131
                case 'language_code':
132
                    $value = $language->languageCode;
133
                    break;
134
                case 'language_name':
135
                case 'name':
136
                    $value = $language->name;
137
                    break;
138
                default:
139
                    throw new \InvalidArgumentException('Language Manager does not support setting references for attribute ' . $reference['attribute']);
140
            }
141
142
            $refs[$reference['identifier']] = $value;
143
        }
144
145
        return $refs;
146
    }
147
}
148