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

Input::create()

Size

Total Lines 15
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
eloc 5
nc 1
nop 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Input.php$0 ➔ __construct() 0 5 1
A Input.php$0 ➔ getType() 0 3 1
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