Completed
Branch job-vuejs (8df734)
by Adam
17:32
created

Radio::getCheckedValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Coyote\Services\FormBuilder\Fields;
4
5
class Radio extends Field
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $template = 'radio';
11
12
    /**
13
     * @var bool
14
     */
15
    protected $checked = false;
16
17
    /**
18
     * @var int
19
     */
20
    protected $checkedValue;
21
22
    /**
23
     * @param $flag
24
     * @return $this
25
     */
26
    public function setChecked($flag)
27
    {
28
        $this->checked = (bool) $flag;
29
30
        return $this;
31
    }
32
33
    /**
34
     * @return bool
35
     */
36
    public function getChecked()
37
    {
38
        return $this->checked;
39
    }
40
41
    /**
42
     * alias
43
     * @return bool
44
     */
45
    public function isChecked()
46
    {
47
        return $this->checked;
48
    }
49
50
    /**
51
     * @return int
52
     */
53
    public function getCheckedValue()
54
    {
55
        return $this->checkedValue;
56
    }
57
58
    /**
59
     * @param int $checkedValue
60
     * @return $this
61
     */
62
    public function setCheckedValue($checkedValue)
63
    {
64
        $this->checkedValue = $checkedValue;
65
66
        return $this;
67
    }
68
69
    /**
70
     * @param string $value
71
     */
72
    public function setValue($value)
73
    {
74
        parent::setValue($value);
75
        $this->checked = $this->checkedValue == $value;
76
    }
77
}
78