Code Duplication    Length = 21-21 lines in 2 locations

src/Models/UserModel.php 1 location

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

src/Models/ElementModel.php 1 location

@@ 261-281 (lines=21) @@
258
     *
259
     * @return array
260
     */
261
    public function refreshFields()
262
    {
263
        if ($this->id === null) {
264
            $this->original = [];
265
            return $this->fields = [];
266
        }
267
268
        $sectionsBackup = isset($this->fields['IBLOCK_SECTION']) ? $this->fields['IBLOCK_SECTION'] : null;
269
270
        $this->fields = static::query()->getById($this->id)->fields;
271
272
        if (!empty($sectionsBackup)) {
273
            $this->fields['IBLOCK_SECTION'] = $sectionsBackup;
274
        }
275
276
        $this->fieldsAreFetched = true;
277
278
        $this->original = $this->fields;
279
280
        return $this->fields;
281
    }
282
283
    /**
284
     * Refresh element's sections and save them to a class field.