ButtonElement::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace dokuwiki\Form;
4
5
/**
6
 * Class ButtonElement
7
 *
8
 * Represents a simple button
9
 *
10
 * @package dokuwiki\Form
11
 */
12
class ButtonElement extends Element
13
{
14
    /** @var string HTML content */
15
    protected $content = '';
16
17
    /**
18
     * @param string $name
19
     * @param string $content HTML content of the button. You have to escape it yourself.
20
     */
21
    public function __construct($name, $content = '')
22
    {
23
        parent::__construct('button', array('name' => $name, 'value' => 1));
24
        $this->content = $content;
25
    }
26
27
    /**
28
     * The HTML representation of this element
29
     *
30
     * @return string
31
     */
32
    public function toHTML()
33
    {
34
        return '<button ' . buildAttributes($this->attrs(), true) . '>'.$this->content.'</button>';
0 ignored issues
show
Bug introduced by
It seems like $this->attrs() targeting dokuwiki\Form\Element::attrs() can also be of type this<dokuwiki\Form\ButtonElement>; however, buildAttributes() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
35
    }
36
37
}
38