Completed
Push — develop ( ac22da...87b1c9 )
by Freddie
02:51
created

Input::form()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 4
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace FlexPHP\Inputs;
4
5
use FlexPHP\Inputs\Builder\FormBuilder;
6
use FlexPHP\Inputs\Builder\InputBuilder;
7
8
/**
9
 * @method static string text(string $name, array $options = [])
10
 */
11
class Input implements InputInterface
12
{
13
    /** @codeCoverageIgnore */
14
    private function __construct()
15
    {
16
    }
17
18
    public static function form(array $inputs, $data = null, array $options = [], string $template = null): string
19
    {
20
        return (new FormBuilder($inputs, $data, $options, $template))->render();
21
    }
22
23
    public static function create(string $type, string $name, array $options = []): string
24
    {
25
        return (new class($type, $name, $options) extends InputBuilder {
26
            public function __construct($type, $name, $options)
27
            {
28
                $this->type = $type;
29
30
                parent::__construct($name, $options);
31
            }
32
33
            protected function getType(): string
34
            {
35
                return $this->type;
36
            }
37
        })->render();
38
    }
39
40
    public static function __callStatic($name, $arguments)
41
    {
42
        return self::create($name, ...$arguments);
0 ignored issues
show
Bug introduced by
$arguments is expanded, but the parameter $name of FlexPHP\Inputs\Input::create() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

42
        return self::create($name, /** @scrutinizer ignore-type */ ...$arguments);
Loading history...
43
    }
44
}
45