Completed
Push — psr2-config ( fbe5f6...b71f24 )
by Andreas
07:19 queued 03:49
created

SettingUndefined   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldHaveDefault() 0 3 1
A html() 0 18 2
1
<?php
2
3
namespace dokuwiki\plugin\config\core\Setting;
4
5
use dokuwiki\plugin\config\core\Configuration;
6
7
/**
8
 * A do-nothing class used to detect settings with no metadata entry.
9
 * Used internaly to hide undefined settings, and generate the undefined settings list.
10
 */
11
class SettingUndefined extends SettingHidden {
12
13
    protected $errorMessage = '_msg_setting_undefined';
14
15
    /** @inheritdoc */
16
    public function shouldHaveDefault() {
17
        return false;
18
    }
19
20
    /** @inheritdoc */
21
    public function html(\admin_plugin_config $plugin, $echo = false) {
22
        // determine the name the meta key would be called
23
        if(preg_match(
24
            '/^(?:plugin|tpl)' . Configuration::KEYMARKER . '.*?' . Configuration::KEYMARKER . '(.*)$/',
25
            $this->getKey(),
26
            $undefined_setting_match
27
        )) {
28
            $undefined_setting_key = $undefined_setting_match[1];
29
        } else {
30
            $undefined_setting_key = $this->getKey();
31
        }
32
33
        $label = '<span title="$meta[\'' . $undefined_setting_key . '\']">$' .
34
            'conf' . '[\'' . $this->getArrayKey() . '\']</span>';
35
        $input = $plugin->getLang($this->errorMessage);
36
37
        return array($label, $input);
38
    }
39
40
}
41