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

Card::render()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 32
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 32
rs 9.7
cc 3
nc 4
nop 2
1
<?php declare(strict_types=1);
2
3
namespace Formularium\Frontend\Vuetify\Element;
4
5
use Formularium\Element;
6
use Formularium\Frontend\HTML\Element\Card as HTMLCard;
7
use Formularium\HTMLNode;
8
use Formularium\Metadata;
9
10
class Card extends VuetifyElement
11
{
12
    public function render(array $parameters, HTMLNode $previous): HTMLNode
13
    {
14
        $atts = [
15
            'class' => 'formularium-card'
16
        ];
17
18
        $contents = [];
19
20
        if ($parameters[HTMLCard::IMAGE] ?? '') {
21
            $contents[] = new HTMLNode(
22
                'v-img',
23
                [
24
                    'src' => $parameters[HTMLCard::IMAGE] ?? '',
25
                ]
26
            );
27
        }
28
29
        if ($parameters[HTMLCard::TITLE] ?? '') {
30
            $contents[] = new HTMLNode(
31
                'v-card-title',
32
                [],
33
                $parameters[HTMLCard::TITLE] ?? ''
34
            );
35
        }
36
37
        return new HTMLNode(
38
            'v-card',
39
            $atts,
40
            new HTMLNode(
41
                'v-card-text',
42
                [],
43
                $parameters[HTMLCard::CONTENT] ?? ''
44
            )
45
        );
46
    }
47
48
    public static function getMetadata(): Metadata
49
    {
50
        $metadata = HTMLCard::getMetadata();
51
        return $metadata;
52
    }
53
}
54