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

AbstractCheckableInput   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 38
ccs 0
cts 13
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isChecked() 0 3 1
A resolveAttributes() 0 4 1
A setChecked() 0 5 1
1
<?php
2
3
namespace WebTheory\Saveyour\Fields;
4
5
use WebTheory\Html\AbstractHtmlElement;
6
use WebTheory\Saveyour\Contracts\CheckableFieldInterface;
7
use WebTheory\Saveyour\Fields\AbstractInput;
8
9
abstract class AbstractCheckableInput extends AbstractInput implements CheckableFieldInterface
10
{
11
    /**
12
     * @var bool
13
     */
14
    protected $checked;
15
16
    /**
17
     * Get the value of checked
18
     *
19
     * @return bool
20
     */
21
    public function isChecked(): bool
22
    {
23
        return $this->checked;
24
    }
25
26
    /**
27
     * Set the value of checked
28
     *
29
     * @param bool $checked
30
     *
31
     * @return self
32
     */
33
    public function setChecked(bool $checked): CheckableFieldInterface
34
    {
35
        $this->checked = $checked;
36
37
        return $this;
38
    }
39
40
    /**
41
     * {@inheritDoc}
42
     */
43
    protected function resolveAttributes(): AbstractHtmlElement
44
    {
45
        return parent::resolveAttributes()
46
            ->addAttribute('checked', $this->checked);
0 ignored issues
show
Bug introduced by
'checked' 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

46
            ->addAttribute(/** @scrutinizer ignore-type */ 'checked', $this->checked);
Loading history...
47
    }
48
}
49