Passed
Push — master ( 4ada59...3080fc )
by Bruno
09:58
created

Renderable_integer::editable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 10
c 1
b 1
f 0
nc 2
nop 3
dl 0
loc 19
rs 9.9332
1
<?php declare(strict_types=1);
2
3
namespace Formularium\Frontend\HTMLValidation\Renderable;
4
5
use Formularium\Datatype\Datatype_integer;
6
use Formularium\Field;
7
use Formularium\HTMLNode;
8
use Formularium\Validator\Max;
9
use Formularium\Validator\Min;
10
11
class Renderable_integer extends Renderable_number
12
{
13
    public function editable($value, Field $field, HTMLNode $previous): HTMLNode
14
    {
15
        $validators = $field->getValidators();
0 ignored issues
show
Unused Code introduced by
The assignment to $validators is dead and can be removed.
Loading history...
16
        /**
17
         * @var HTMLNode $element
18
         */
19
        $element = $this->getInput($previous);
20
        if (!$element) {
0 ignored issues
show
introduced by
$element is of type Formularium\HTMLNode, thus it always evaluated to true.
Loading history...
21
            var_dump("no element");
0 ignored issues
show
Security Debugging Code introduced by
var_dump('no element') looks like debug code. Are you sure you do not want to remove it?
Loading history...
22
            return $previous;
23
        }
24
25
        /** @var Datatype_integer $datatype */
26
        $datatype = $field->getDatatype();
27
        var_dump('max', $field->getValidators(), Max::class, $field->getValidatorOption(Max::class, 'value', $datatype->getMaxValue()));
28
        $element->setAttribute('min', $field->getValidatorOption(Min::class, 'value', $datatype->getMinValue()));
29
        $element->setAttribute('max', $field->getValidatorOption(Max::class, 'value', $datatype->getMaxValue()));
30
31
        return parent::editable($value, $field, $previous);
32
    }
33
}
34