Submit   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 3 2
A setValue() 0 3 1
A setTitle() 0 3 1
A renderInput() 0 5 1
1
<?php
2
3
namespace kalanis\kw_forms\Controls;
4
5
6
/**
7
 * Class Submit
8
 * @package kalanis\kw_forms\Controls
9
 * Form element for submit button
10
 */
11
class Submit extends Button
12
{
13
    protected string $templateInput = '<input type="submit" value="%1$s"%2$s />';
14
    protected $originalValue = 'submit';
15
16
    /**
17
     * Check if form was sent by this button
18
     * @var boolean
19
     */
20
    protected bool $submitted = false;
21
22 2
    public function setValue($value): void
23
    {
24 2
        $this->submitted = !empty($value);
25 2
    }
26
27 2
    public function getValue()
28
    {
29 2
        return $this->submitted ? $this->originalValue : '' ;
30
    }
31
32 1
    public function setTitle(string $title): void
33
    {
34 1
        $this->originalValue = $title;
35 1
    }
36
37 2
    public function renderInput($attributes = null): string
38
    {
39 2
        $this->addAttributes($attributes);
40 2
        $this->setAttribute('name', $this->getKey());
41 2
        return $this->wrapIt(sprintf($this->templateInput, strval($this->originalValue), $this->renderAttributes(), $this->renderChildren()), $this->wrappersInput);
42
    }
43
}
44