Passed
Push — master ( 1bc594...fed342 )
by Bruno
07:08
created

RenderableBladeTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A viewable() 0 6 2
A editable() 0 12 4
1
<?php declare(strict_types=1);
2
3
namespace Formularium\Frontend\Blade;
4
5
use Formularium\Field;
6
use Formularium\HTMLElement;
7
8
trait RenderableBladeTrait
9
{
10
    public function viewable($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

10
    public function viewable(/** @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...
11
    {
12
        foreach ($previous->get('formularium-value') as $input) {
13
            $input->setContent("{{Request::input('" . $field->getName() . "')}}");
14
        }
15
        return $previous;
16
    }
17
18
    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

18
    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...
19
    {
20
        foreach ($previous->get('input') as $input) {
21
            $input->setAttribute('value', "{{Request::input('" . $field->getName() . "')}}");
22
        }
23
        foreach ($previous->get('textarea') as $textarea) {
24
            $input->setContent("{{Request::input('" . $field->getName() . "')}}");
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $input seems to be defined by a foreach iteration on line 20. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
25
        }
26
        foreach ($previous->get('select') as $input) {
27
            $input->setAttribute('value', "{{Request::input('" . $field->getName() . "')}}");
28
        }
29
        return $previous;
30
    }
31
}
32