Test Failed
Push — master ( e97986...2933e0 )
by Bruno
19:41 queued 09:43
created

Button   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 21
c 1
b 0
f 0
dl 0
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 21 4
A getMetadata() 0 11 1
1
<?php declare(strict_types=1);
2
3
namespace Formularium\Frontend\Vuetify\Element;
4
5
use Formularium\Element;
6
use Formularium\Exception\Exception;
7
use Formularium\HTMLNode;
8
use Formularium\Frontend\HTML\Element\Button as HTMLButton;
9
use Formularium\Metadata;
10
use Formularium\MetadataParameter;
11
12
class Button extends VuetifyElement
13
{
14
    public function render(array $parameters, HTMLNode $previous): HTMLNode
15
    {
16
        $previous->setTag('v-btn');
17
18
        $this->color($parameters, $previous);
19
20
        $size = $parameters[self::SIZE] ?? '';
21
        switch ($size) {
22
            case self::SIZE_LARGE:
23
                $previous->addAttribute('large');
24
                break;
25
            case self::SIZE_SMALL:
26
                $previous->addAttribute('small');
27
                break;
28
        }
29
30
        if ($parameters[self::ICON] ?? '') {
31
            $previous->addContent('<v-icon>' . $parameters[self::ICON] . '</v-icon>');
32
        }
33
34
        return $previous;
35
    }
36
37
    public static function getMetadata(): Metadata
38
    {
39
        $metadata = HTMLButton::getMetadata();
40
        $metadata->appendParameter(
41
            new MetadataParameter(
42
                HTMLButton::COLOR,
43
                'string',
44
                'Button color. Supports all vuetify colors. Default: primary.'
45
            )
46
        );
47
        return $metadata;
48
    }
49
}
50