| Total Complexity | 4 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php declare(strict_types=1); |
||
| 10 | class Button extends Element |
||
| 11 | { |
||
| 12 | const COLOR = 'color'; |
||
| 13 | const COLOR_PRIMARY = 'primary'; |
||
| 14 | const COLOR_LINK = 'link'; |
||
| 15 | const COLOR_INFO = 'info'; |
||
| 16 | const COLOR_SUCCESS = 'success'; |
||
| 17 | const COLOR_WARNING = 'warning'; |
||
| 18 | const COLOR_ERROR = 'error'; |
||
| 19 | |||
| 20 | const TYPE = 'type'; |
||
| 21 | |||
| 22 | public function render(array $parameters, HTMLNode $previous): HTMLNode |
||
| 23 | { |
||
| 24 | $node = new HTMLNode('button'); |
||
| 25 | |||
| 26 | $node->setAttributes([ |
||
| 27 | 'type' => $parameters[self::TYPE] ?? 'button', |
||
| 28 | 'class' => '', |
||
| 29 | ]); |
||
| 30 | |||
| 31 | $node->setContent($parameters[self::LABEL] ?? ''); |
||
| 32 | |||
| 33 | foreach ([static::DISABLED, static::READONLY] as $v) { |
||
| 34 | if ($parameters[$v] ?? false) { |
||
| 35 | $node->setAttribute($v, $v); |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | return $node; |
||
| 40 | } |
||
| 41 | |||
| 42 | public static function getMetadata(): Metadata |
||
| 62 | ) |
||
| 63 | ] |
||
| 67 |