Passed
Push — main ( 3b40ce...057ebd )
by James Ekow Abaka
11:01
created

Checkable::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace ntentan\honam\engines\php\helpers\form;
4
5
/**
6
 * A regular checkbox with a label.
7
 */
8
class Checkable extends Field
9
{
10
   /**
11
     * The value that this field should contain if this checkbox is checked.
12
     */
13
    protected $checkedValue = 1;
14
15
    /**
16
     * Sets the value that should be assigned as the checked value for
17
     * this check box.
18
     * @param string $checkedValue
19
     * @return CheckableField
0 ignored issues
show
Bug introduced by
The type ntentan\honam\engines\ph...ers\form\CheckableField was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
     */
21
    public function setCheckedValue($checkedValue)
22
    {
23
        $this->checkedValue = $checkedValue;
24
        return $this;
25
    }
26
27
    /**
28
     * Gets and returns the checkedValue for the check box.
29
     * @return string
30
     */
31
    public function getCheckedValue()
32
    {
33
        return $this->checkedValue;
34
    }
35
36
    public function render()
37
    {
38
        if ($this->getCheckedValue() == (string)$this->getValue()) {
39
            $this->setAttribute('checked', 'checked');
40
        }
41
42
        return parent::render();
43
    }
44
}
45