Code Duplication    Length = 27-30 lines in 3 locations

Core/Executor/LanguageManager.php 1 location

@@ 85-114 (lines=30) @@
82
     * @throws \InvalidArgumentException When trying to assign a reference to an unsupported attribute
83
     * @return array key: the reference names, values: the reference values
84
     */
85
    protected function getReferencesValues($language, array $references, $step)
86
    {
87
        $refs = array();
88
89
        foreach ($references as $reference) {
90
91
            switch ($reference['attribute']) {
92
                case 'language_id':
93
                case 'id':
94
                    $value = $language->id;
95
                    break;
96
                case 'enabled':
97
                    $value = $language->enabled;
98
                    break;
99
                case 'language_code':
100
                    $value = $language->languageCode;
101
                    break;
102
                case 'language_name':
103
                case 'name':
104
                    $value = $language->name;
105
                    break;
106
                default:
107
                    throw new \InvalidArgumentException('Language Manager does not support setting references for attribute ' . $reference['attribute']);
108
            }
109
110
            $refs[$reference['identifier']] = $value;
111
        }
112
113
        return $refs;
114
    }
115
}
116

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/UserManager.php 1 location

@@ 218-246 (lines=29) @@
215
     * @throws \InvalidArgumentException When trying to assign a reference to an unsupported attribute
216
     * @return array key: the reference names, values: the reference values
217
     */
218
    protected function getReferencesValues($user, array $references, $step)
219
    {
220
        $refs = array();
221
222
        foreach ($references as $reference) {
223
224
            switch ($reference['attribute']) {
225
                case 'user_id':
226
                case 'id':
227
                    $value = $user->id;
228
                    break;
229
                case 'email':
230
                    $value = $user->email;
231
                    break;
232
                case 'enabled':
233
                    $value = $user->enabled;
234
                    break;
235
                case 'login':
236
                    $value = $user->login;
237
                    break;
238
                default:
239
                    throw new \InvalidArgumentException('User Manager does not support setting references for attribute ' . $reference['attribute']);
240
            }
241
242
            $refs[$reference['identifier']] = $value;
243
        }
244
245
        return $refs;
246
    }
247
}
248