| Total Complexity | 5 |
| Total Lines | 71 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | abstract class AbstractInput extends AbstractHelper |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | protected $type = "text"; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @var array |
||
| 32 | */ |
||
| 33 | protected $attributes = []; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param string $name |
||
| 37 | * @param string|null $value |
||
| 38 | * @param array $attributes |
||
| 39 | * |
||
| 40 | * @return AbstractInput |
||
| 41 | */ |
||
| 42 | 5 | public function __invoke( |
|
| 43 | string $name, |
||
| 44 | string $value = null, |
||
| 45 | array $attributes = [] |
||
| 46 | ): AbstractInput { |
||
| 47 | 5 | $this->attributes = [ |
|
| 48 | 5 | "type" => $this->type, |
|
| 49 | 5 | "name" => $name, |
|
| 50 | ]; |
||
| 51 | |||
| 52 | 5 | if (!isset($attributes["id"])) { |
|
| 53 | 5 | $this->attributes["id"] = $name; |
|
| 54 | } |
||
| 55 | |||
| 56 | 5 | $this->setValue($value); |
|
| 57 | |||
| 58 | 5 | $this->attributes = array_merge($this->attributes, $attributes); |
|
| 59 | |||
| 60 | 5 | return $this; |
|
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Returns the HTML for the input. |
||
| 65 | * |
||
| 66 | * @return string |
||
| 67 | */ |
||
| 68 | 4 | public function __toString() |
|
| 77 | ); |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Sets the value of the element |
||
| 82 | * |
||
| 83 | * @param string|null $value |
||
| 84 | * |
||
| 85 | * @return AbstractInput |
||
| 86 | */ |
||
| 87 | 5 | public function setValue(string $value = null): AbstractInput |
|
| 96 |