Passed
Push — master ( 5e4c5e...9eef8c )
by Bruno
07:32
created

Upload   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 29
dl 0
loc 55
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 40 1
A getMetadata() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace Formularium\Frontend\Bulma\Element;
4
5
use Formularium\Element;
6
use Formularium\HTMLNode;
7
use Formularium\Metadata;
8
use Formularium\Frontend\HTML\Element\Upload as HTMLUpload;
9
use Formularium\Frontend\HTML\Framework as HTMLFramework;
10
11
class Upload extends Element
12
{
13
    public function render(array $parameters, HTMLNode $previous): HTMLNode
14
    {
15
        $id = 'upload' . HTMLFramework::counter();
16
        return HTMLNode::factory(
17
            'div',
18
            [
19
                'class' => 'formularium-upload file'
20
            ],
21
            [
22
                HTMLNode::factory(
23
                    'label',
24
                    [
25
                        'class' => 'formularium-label file-label',
26
                        'for' => $id
27
                    ],
28
                    [
29
                        HTMLNode::factory(
30
                            'input',
31
                            [
32
                                'id' => $id,
33
                                'class' => 'formularium-input file-input',
34
                                'type' => 'file'
35
                            ]
36
                        ),
37
                        HTMLNode::factory(
38
                            'span',
39
                            ['class' => 'file-cta'],
40
                            [
41
                                HTMLNode::factory(
42
                                    'span',
43
                                    ['class' => 'file-icon'],
44
                                    HTMLNode::factory(
45
                                        'i',
46
                                        ['class' => 'fas fa-upload']
47
                                    )
48
                                ),
49
                                HTMLNode::factory(
50
                                    'span',
51
                                    ['class' => 'file-label'],
52
                                    $parameters[self::LABEL] ?? 'Upload file'
53
                                )
54
                            ]
55
                        )
56
                    ]
57
                ),
58
            ]
59
        );
60
    }
61
62
    public static function getMetadata(): Metadata
63
    {
64
        $metadata = HTMLUpload::getMetadata();
65
        return $metadata;
66
    }
67
}
68