Checkbox   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 29
ccs 9
cts 9
cp 1
rs 10
c 2
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fillTemplate() 0 3 1
A set() 0 6 1
A getOriginalValue() 0 3 1
1
<?php
2
3
namespace kalanis\kw_forms\Controls;
4
5
6
use kalanis\kw_forms\Interfaces\IOriginalValue;
7
8
9
/**
10
 * Class Checkbox
11
 * @package kalanis\kw_forms\Controls
12
 * Form element for checkboxes
13
 */
14
class Checkbox extends AControl implements IOriginalValue
15
{
16
    use TChecked;
17
18
    private static int $uniqid = 0;
19
    protected string $templateInput = '<input type="checkbox" value="%1$s"%2$s />';
20
21
    /**
22
     * @param string $alias
23
     * @param string|int|float|null $value
24
     * @param string $label
25
     * @return $this
26
     */
27 5
    public function set(string $alias, $value = null, string $label = ''): self
28
    {
29 5
        $this->setEntry($alias, $value, $label);
30 5
        $this->setAttribute('id', sprintf('%s_%s', $this->getKey(), self::$uniqid));
31 5
        self::$uniqid++;
32 5
        return $this;
33
    }
34
35 1
    public function getOriginalValue()
36
    {
37 1
        return $this->originalValue;
38
    }
39
40 5
    protected function fillTemplate(): string
41
    {
42 5
        return '%2$s %1$s';
43
    }
44
}
45