Failed Conditions
Push — psr2 ( 8eb28c...c68e26 )
by Andreas
28s queued 20s
created

SettingString   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B html() 0 22 5
1
<?php
2
3
namespace dokuwiki\plugin\config\core\Setting;
4
5
/**
6
 * Class setting_string
7
 */
8
class SettingString extends Setting {
9
    /** @inheritdoc */
10
    public function html(\admin_plugin_config $plugin, $echo = false) {
11
        $disable = '';
12
13
        if($this->isProtected()) {
14
            $value = $this->protected;
15
            $disable = 'disabled="disabled"';
16
        } else {
17
            if($echo && $this->error) {
18
                $value = $this->input;
19
            } else {
20
                $value = is_null($this->local) ? $this->default : $this->local;
21
            }
22
        }
23
24
        $key = htmlspecialchars($this->key);
25
        $value = htmlspecialchars($value);
26
27
        $label = '<label for="config___' . $key . '">' . $this->prompt($plugin) . '</label>';
28
        $input = '<input id="config___' . $key . '" name="config[' . $key .
29
            ']" type="text" class="edit" value="' . $value . '" ' . $disable . '/>';
30
        return array($label, $input);
31
    }
32
}
33