Passed
Push — master ( 089a6d...7b13b9 )
by Bruno
06:38
created

Renderable_file   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 27
c 1
b 0
f 0
dl 0
loc 43
ccs 0
cts 36
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A viewable() 0 3 1
A _editable() 0 34 1
1
<?php declare(strict_types=1);
2
3
namespace Formularium\Frontend\Bootstrap\Renderable;
4
5
use Formularium\Field;
6
use Formularium\Frontend\Bootstrap\RenderableBootstrapInputTrait;
7
use Formularium\Frontend\Bootstrap\RenderableBootstrapTrait;
8
use Formularium\HTMLElement;
9
10
class Renderable_file extends \Formularium\Renderable
11
{
12
    use RenderableBootstrapTrait;
13
14
    public function viewable($value, Field $field, HTMLElement $previous): HTMLElement
15
    {
16
        return $previous;
17
    }
18
19
    public function _editable($value, Field $field, HTMLElement $previous): HTMLElement
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

19
    public function _editable(/** @scrutinizer ignore-unused */ $value, Field $field, HTMLElement $previous): HTMLElement

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $field is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

19
    public function _editable($value, /** @scrutinizer ignore-unused */ Field $field, HTMLElement $previous): HTMLElement

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
20
    {
21
        // add extra classes
22
        $input = $previous->get('input')[0];
23
        $input->addAttribute('class', 'custom-file-input');
24
        $label = $previous->get('label')[0];
25
        
26
        return HTMLElement::factory(
27
            'div',
28
            [],
29
            [
30
                $label,
31
                HTMLElement::factory(
32
                    'div',
33
                    ['class' => "input-group mb-3"],
34
                    [
35
                        HTMLElement::factory(
36
                            'div',
37
                            ['class' => "input-group-prepend"],
38
                            HTMLElement::factory(
39
                                'span',
40
                                ['class' => "input-group-text"],
41
                                'Upload'
42
                            )
43
                        ),
44
                        HTMLElement::factory(
45
                            'div',
46
                            ['class' => "custom-file"],
47
                            [
48
                                $input,
49
                                HTMLElement::factory(
50
                                    'label',
51
                                    ['class' => "custom-file-label"],
52
                                    'Choose file'
53
                                )
54
                            ]
55
                        )
56
                    ]
57
                )
58
            ]
59
        );
60
    }
61
}
62