Code Duplication    Length = 18-18 lines in 2 locations

src/Models/UserModel.php 1 location

@@ 173-190 (lines=18) @@
170
     *
171
     * @return array
172
     */
173
    public function refreshFields()
174
    {
175
        if ($this->id === null) {
176
            return  $this->fields = [];
177
        }
178
179
        $groupBackup = isset($this->fields['GROUP_ID']) ? $this->fields['GROUP_ID'] : null;
180
181
        $this->fields = static::query()->getById($this->id)->fields;
182
183
        if ($groupBackup) {
184
            $this->fields['GROUP_ID'] = $groupBackup;
185
        }
186
187
        $this->fieldsAreFetched = true;
188
189
        return $this->fields;
190
    }
191
192
    /**
193
     * Refresh user groups and save them to a class field.

src/Models/ElementModel.php 1 location

@@ 223-240 (lines=18) @@
220
     *
221
     * @return array
222
     */
223
    public function refreshFields()
224
    {
225
        if ($this->id === null) {
226
            return  $this->fields = [];
227
        }
228
229
        $sectionsBackup = isset($this->fields['IBLOCK_SECTION']) ? $this->fields['IBLOCK_SECTION'] : null;
230
231
        $this->fields = static::query()->getById($this->id)->fields;
232
233
        if (!empty($sectionsBackup)) {
234
            $this->fields['IBLOCK_SECTION'] = $sectionsBackup;
235
        }
236
237
        $this->fieldsAreFetched = true;
238
239
        return $this->fields;
240
    }
241
242
    /**
243
     * Refresh element's sections and save them to a class field.