Passed
Push — master ( 4c5faf...429320 )
by Chris
04:23
created

AbstractInput::resolveAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 2
rs 10
1
<?php
2
3
namespace WebTheory\Saveyour\Fields;
4
5
use WebTheory\Html\AbstractHtmlElement;
6
use WebTheory\Saveyour\Contracts\FormFieldInterface;
7
8
abstract class AbstractInput extends AbstractStandardFormControl implements FormFieldInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $type = 'text';
14
15
    /**
16
     * @var string
17
     */
18
    protected $dataList;
19
20
    /**
21
     * Get the value of type
22
     *
23
     * @return string
24
     */
25
    public function getType(): string
26
    {
27
        return $this->type;
28
    }
29
30
    /**
31
     *
32
     */
33
    protected function resolveAttributes(): AbstractHtmlElement
34
    {
35
        return parent::resolveAttributes()
36
            ->addAttribute('type', $this->type)
0 ignored issues
show
Bug introduced by
'type' of type string is incompatible with the type array expected by parameter $attribute of WebTheory\Html\AbstractHtmlElement::addAttribute(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
            ->addAttribute(/** @scrutinizer ignore-type */ 'type', $this->type)
Loading history...
37
            ->addAttribute('value', $this->value)
38
            ->addAttribute('datalist', $this->dataList);
39
    }
40
41
    /**
42
     *
43
     */
44
    protected function renderHtmlMarkup(): string
45
    {
46
        return $this->open('input', $this->attributes);
47
    }
48
}
49