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

SettingPassword   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
B update() 0 13 5
A html() 0 11 2
1
<?php
2
3
namespace dokuwiki\plugin\config\core\Setting;
4
5
/**
6
 * Class setting_password
7
 */
8
class SettingPassword extends SettingString {
9
10
    protected $code = 'plain';  // mechanism to be used to obscure passwords
11
12
    /** @inheritdoc */
13
    public function update($input) {
14
        if($this->isProtected()) return false;
15
        if(!$input) return false;
16
17
        if($this->pattern && !preg_match($this->pattern, $input)) {
18
            $this->error = true;
19
            $this->input = $input;
20
            return false;
21
        }
22
23
        $this->local = conf_encodeString($input, $this->code);
24
        return true;
25
    }
26
27
    /** @inheritdoc */
28
    public function html(\admin_plugin_config $plugin, $echo = false) {
29
30
        $disable = $this->isProtected() ? 'disabled="disabled"' : '';
31
32
        $key = htmlspecialchars($this->key);
33
34
        $label = '<label for="config___' . $key . '">' . $this->prompt($plugin) . '</label>';
35
        $input = '<input id="config___' . $key . '" name="config[' . $key .
36
            ']" autocomplete="off" type="password" class="edit" value="" ' . $disable . ' />';
37
        return array($label, $input);
38
    }
39
}
40