Card   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 5
eloc 22
c 2
b 1
f 0
dl 0
loc 46
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 37 4
A getMetadata() 0 4 1
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 = $previous->getContent();
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
        if ($parameters[HTMLCard::CONTENT] ?? '') {
38
            $contents[] = new HTMLNode(
39
                'v-card-text',
40
                [],
41
                $parameters[HTMLCard::CONTENT] ?? ''
42
            );
43
        }
44
45
        return new HTMLNode(
46
            'v-card',
47
            $atts,
48
            $contents
49
        );
50
    }
51
52
    public static function getMetadata(): Metadata
53
    {
54
        $metadata = HTMLCard::getMetadata();
55
        return $metadata;
56
    }
57
}
58