Button   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 18
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A set() 0 12 5
1
<?php
2
3
namespace kalanis\kw_forms\Controls;
4
5
6
/**
7
 * Class Button
8
 * @package kalanis\kw_forms\Controls
9
 * Form element for button
10
 */
11
class Button extends AControl
12
{
13
    protected string $templateLabel = '';
14
    protected string $templateInput = '<input type="button" value="%1$s"%2$s />';
15
    protected $originalValue = 'button';
16
17 8
    public function set(string $alias, string $title = ''): self
18
    {
19 8
        if (empty($title) && !empty($alias)) {
20 1
            $title = $alias;
21
        }
22 8
        $title = empty($title) ? strval($this->originalValue) : $title ;
23 8
        if (empty($alias)) {
24 2
            $alias = $title;
25
        }
26 8
        $this->setEntry($alias, $title, $title);
27 8
        $this->setAttribute('id', $this->getKey());
28 8
        return $this;
29
    }
30
}
31