Passed
Push — master ( 14b5da...159fc4 )
by Bruno
07:51
created

RenderableVueTrait::editable()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 14
rs 9.9666
cc 4
nc 8
nop 3
1
<?php
2
3
namespace Formularium\Frontend\Vue;
4
5
use Formularium\Field;
6
use Formularium\HTMLElement;
7
8
trait RenderableVueTrait
9
{
10
    public function viewable($value, Field $field, HTMLElement $previous): HTMLElement
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

10
    public function viewable($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...
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
        return $previous;
13
    }
14
15
    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

15
    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...
16
    {
17
        foreach ($previous->get('input') as $input) {
18
            $input->setAttribute('v-model', $field->getName())
19
                ->removeAttribute('value');
20
        }
21
        foreach ($previous->get('textarea') as $textarea) {
22
            $textarea->setAttribute('v-model', $field->getName());
23
        }
24
        foreach ($previous->get('select') as $input) {
25
            $input->setAttribute('v-model', $field->getName())
26
                ->removeAttribute('value');
27
        }
28
        return $previous;
29
    }
30
}
31