Code Duplication    Length = 18-18 lines in 2 locations

src/Models/UserModel.php 1 location

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

src/Models/ElementModel.php 1 location

@@ 246-263 (lines=18) @@
243
     *
244
     * @return array
245
     */
246
    public function refreshFields()
247
    {
248
        if ($this->id === null) {
249
            return  $this->fields = [];
250
        }
251
252
        $sectionsBackup = isset($this->fields['IBLOCK_SECTION']) ? $this->fields['IBLOCK_SECTION'] : null;
253
254
        $this->fields = static::query()->getById($this->id)->fields;
255
256
        if (!empty($sectionsBackup)) {
257
            $this->fields['IBLOCK_SECTION'] = $sectionsBackup;
258
        }
259
260
        $this->fieldsAreFetched = true;
261
262
        return $this->fields;
263
    }
264
265
    /**
266
     * Refresh element's sections and save them to a class field.