Input::form()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
nc 1
nop 4
dl 0
loc 3
ccs 2
cts 2
cp 1
cc 1
crap 1
rs 10
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of FlexPHP.
4
 *
5
 * (c) Freddie Gar <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace FlexPHP\Inputs;
11
12
use FlexPHP\Inputs\Builder\FormBuilder;
13
use FlexPHP\Inputs\Builder\InputBuilder;
14
15
/**
16
 * @method static string text(string $name, array $options = [])
17
 */
18
final class Input implements InputInterface
19
{
20
    /**
21
     * @param array<string> $inputs
22
     * @param array<string> $data
23
     * @param array<string> $options
24
     */
25 1
    public static function form(array $inputs, array $data = [], array $options = [], string $template = ''): string
26
    {
27 1
        return (new FormBuilder($inputs, $data, $options, $template))->render();
28
    }
29
30 18
    public static function create(string $type, string $name, array $options = []): string
31
    {
32 18
        return (new class($type, $name, $options) extends InputBuilder {
33
            public function __construct(string $type, string $name, array $options)
34
            {
35 18
                $this->type = $type;
36
37 18
                parent::__construct($name, $options);
38 18
            }
39
40
            protected function getType(): string
41
            {
42 18
                return $this->type;
43
            }
44 18
        })->render();
45
    }
46
47
    /** @codeCoverageIgnore */
48
    private function __construct()
49
    {
50
    }
51
52
    /**
53
     * @param string $type
54
     * @param array<int, string> $arguments
55
     *
56
     * @return string
57
     */
58 2
    public static function __callStatic($type, $arguments)
59
    {
60 2
        return self::create($type, ...$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

60
        return self::create($type, /** @scrutinizer ignore-type */ ...$arguments);
Loading history...
61
    }
62
}
63