Passed
Push — master ( 16a53c...ab92ed )
by Bruno
05:36
created

Upload::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
nc 1
nop 2
dl 0
loc 27
rs 9.6666
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Formularium\Frontend\Bootstrapvue\Element;
4
5
use Formularium\Element;
6
use Formularium\HTMLNode;
7
use Formularium\Frontend\HTML\Element\Upload as HTMLUpload;
8
use Formularium\Frontend\HTML\Framework as HTMLFramework;
9
use Formularium\Metadata;
10
use Formularium\MetadataParameter;
11
12
class Upload extends Element
13
{
14
    public function render(array $parameters, HTMLNode $previous): HTMLNode
15
    {
16
        $id = 'upload' . HTMLFramework::counter();
17
        $vmodel = 'file'; // TODO: test
18
        return HTMLNode::factory(
19
            'div',
20
            [
21
                'class' => 'formularium-upload'
22
            ],
23
            HTMLNode::factory(
24
                'b-form-group',
25
                [
26
                    'label' => $parameters[self::LABEL] ?? '',
27
                    'label-for' => $id,
28
                    'label-cols-sm' => "2"
29
                    // TODO size:
30
                ],
31
                HTMLNode::factory(
32
                    'b-form-file',
33
                    [
34
                        'id' => $id,
35
                        'class' => 'formularium-label',
36
                        'v-model' => $vmodel,
37
                        ':state' => "Boolean($vmodel)",
38
                        'placeholder' => $parameters[self::COMMENT] ?? ''
39
                    ],
40
                    $parameters[self::LABEL] ?? ''
41
                )
42
            )
43
        );
44
    }
45
46
    public static function getMetadata(): Metadata
47
    {
48
        $metadata = HTMLUpload::getMetadata();
49
        return $metadata;
50
    }
51
}
52