Code Duplication    Length = 12-19 lines in 4 locations

src/Form/EmbeddedForm.php 1 location

@@ 265-281 (lines=17) @@
262
     *
263
     * @return Field|$this
264
     */
265
    public function __call($method, $arguments)
266
    {
267
        if ($className = Form::findFieldClass($method)) {
268
            $column = array_get($arguments, 0, '');
269
270
            /** @var Field $field */
271
            $field = new $className($column, array_slice($arguments, 1));
272
273
            $field->setForm($this->parent);
274
275
            $this->pushField($field);
276
277
            return $field;
278
        }
279
280
        return $this;
281
    }
282
}
283

src/Form/NestedForm.php 1 location

@@ 369-387 (lines=19) @@
366
     *
367
     * @return mixed
368
     */
369
    public function __call($method, $arguments)
370
    {
371
        if ($className = Form::findFieldClass($method)) {
372
            $column = array_get($arguments, 0, '');
373
374
            /* @var Field $field */
375
            $field = new $className($column, array_slice($arguments, 1));
376
377
            $field->setForm($this->form);
378
379
            $field = $this->formatField($field);
380
381
            $this->pushField($field);
382
383
            return $field;
384
        }
385
386
        return $this;
387
    }
388
}
389

src/Form.php 1 location

@@ 1407-1418 (lines=12) @@
1404
     *
1405
     * @return Field|void
1406
     */
1407
    public function __call($method, $arguments)
1408
    {
1409
        if ($className = static::findFieldClass($method)) {
1410
            $column = array_get($arguments, 0, ''); //[0];
1411
1412
            $element = new $className($column, array_slice($arguments, 1));
1413
1414
            $this->pushField($element);
1415
1416
            return $element;
1417
        }
1418
    }
1419
1420
    /**
1421
     * Render the contents of the form when casting to string.

src/Widgets/Form.php 1 location

@@ 270-281 (lines=12) @@
267
     *
268
     * @return Field|null
269
     */
270
    public function __call($method, $arguments)
271
    {
272
        if ($className = static::findFieldClass($method)) {
273
            $name = array_get($arguments, 0, '');
274
275
            $element = new $className($name, array_slice($arguments, 1));
276
277
            $this->pushField($element);
278
279
            return $element;
280
        }
281
    }
282
283
    /**
284
     * Render the form.