AbstractCheckableInput   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 37
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isChecked() 0 3 1
A setChecked() 0 5 1
A resolveAttributes() 0 6 1
1
<?php
2
3
namespace WebTheory\Saveyour\Field\Type\Abstracts;
4
5
use WebTheory\Saveyour\Contracts\Field\CheckableFieldInterface;
6
7
abstract class AbstractCheckableInput extends AbstractInput implements CheckableFieldInterface
8
{
9
    protected ?bool $checked = null;
10
11
    /**
12
     * Get the value of checked
13
     *
14
     * @return bool
15
     */
16
    public function isChecked(): bool
17
    {
18
        return $this->checked;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->checked could return the type null which is incompatible with the type-hinted return boolean. Consider adding an additional type-check to rule them out.
Loading history...
19
    }
20
21
    /**
22
     * Set the value of checked
23
     *
24
     * @param bool $checked
25
     *
26
     * @return $this
27
     */
28
    public function setChecked(bool $checked): CheckableFieldInterface
29
    {
30
        $this->checked = $checked;
31
32
        return $this;
33
    }
34
35
    /**
36
     * @return $this
37
     */
38
    protected function resolveAttributes(): AbstractCheckableInput
39
    {
40
        parent::resolveAttributes()
41
            ->addAttribute('checked', $this->checked);
42
43
        return $this;
44
    }
45
}
46