Renderable_file   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 27
c 1
b 0
f 0
dl 0
loc 51
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\HTMLNode;
9
10
class Renderable_file extends \Formularium\Renderable
11
{
12
    use RenderableBootstrapTrait;
13
14
    public function viewable($value, Field $field, HTMLNode $previous): HTMLNode
15
    {
16
        return $previous;
17
    }
18
19
    /**
20
     * Subcall of wrapper editable()
21
     *
22
     * @param mixed $value
23
     * @param Field $field
24
     * @param HTMLNode $previous
25
     * @return HTMLNode
26
     */
27
    public function _editable($value, Field $field, HTMLNode $previous): HTMLNode
0 ignored issues
show
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

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

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 $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

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

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...
28
    {
29
        // add extra classes
30
        $input = $previous->get('input')[0];
31
        $input->addAttribute('class', 'custom-file-input');
32
        $label = $previous->get('label')[0];
33
        
34
        return HTMLNode::factory(
35
            'div',
36
            [],
37
            [
38
                $label,
39
                HTMLNode::factory(
40
                    'div',
41
                    ['class' => "input-group mb-3"],
42
                    [
43
                        HTMLNode::factory(
44
                            'div',
45
                            ['class' => "input-group-prepend"],
46
                            HTMLNode::factory(
47
                                'span',
48
                                ['class' => "input-group-text"],
49
                                'Upload'
50
                            )
51
                        ),
52
                        HTMLNode::factory(
53
                            'div',
54
                            ['class' => "custom-file"],
55
                            [
56
                                $input,
57
                                HTMLNode::factory(
58
                                    'label',
59
                                    ['class' => "custom-file-label formularium-file-name"],
60
                                    'Choose file'
61
                                )
62
                            ]
63
                        )
64
                    ]
65
                )
66
            ]
67
        );
68
    }
69
}
70