Code Duplication    Length = 21-23 lines in 2 locations

src/Form/EmbeddedForm.php 1 location

@@ 281-301 (lines=21) @@
278
     *
279
     * @return Field|$this
280
     */
281
    public function __call($method, $arguments)
282
    {
283
        if ($className = Form::findFieldClass($method)) {
284
            $column = Arr::get($arguments, 0, '');
285
286
            /** @var Field $field */
287
            $field = new $className($column, array_slice($arguments, 1));
288
289
            if ($this->parent instanceof WidgetForm) {
290
                $field->setWidgetForm($this->parent);
291
            } else {
292
                $field->setForm($this->parent);
293
            }
294
295
            $this->pushField($field);
296
297
            return $field;
298
        }
299
300
        return $this;
301
    }
302
}
303

src/Form/NestedForm.php 1 location

@@ 442-464 (lines=23) @@
439
     *
440
     * @return mixed
441
     */
442
    public function __call($method, $arguments)
443
    {
444
        if ($className = Form::findFieldClass($method)) {
445
            $column = Arr::get($arguments, 0, '');
446
447
            /* @var Field $field */
448
            $field = new $className($column, array_slice($arguments, 1));
449
450
            if ($this->form instanceof WidgetForm) {
451
                $field->setWidgetForm($this->form);
452
            } else {
453
                $field->setForm($this->form);
454
            }
455
456
            $field = $this->formatField($field);
457
458
            $this->pushField($field);
459
460
            return $field;
461
        }
462
463
        return $this;
464
    }
465
}
466