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
![]() |
|||
61 | } |
||
62 | } |
||
63 |