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

Renderable_file::viewable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
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