Button::set()   A
last analyzed

Complexity

Conditions 5
Paths 8

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 8
nc 8
nop 2
dl 0
loc 12
ccs 9
cts 9
cp 1
crap 5
rs 9.6111
c 1
b 0
f 0
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