Settings::getDefaultSettings()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 6
cp 0
crap 2
1
<?php
2
3
namespace SES;
4
5
/**
6
 * File defining the settings for the SemanticSignup extension.
7
 * More info can be found at http://www.mediawiki.org/wiki/Extension:SemanticSignup#Settings
8
 *
9
 * NOTICE:
10
 * Changing one of these settings can be done by assigning to $egSemanticSignupSettings.
11
 *
12
 * @since 0.3
13
 *
14
 * @license GNU GPL v3+
15
 * @author Jeroen De Dauw <[email protected]>
16
 */
17
class Settings {
18
19
	protected static function getDefaultSettings() {
20
		return array(
21
			'requireName' => false,
22
			'formName' => '',
23
			'botName' => '',
24
			'useCaptcha' => true,
25
		);
26
	}
27
28 1
	public static function getSettings() {
29 1
		static $settings = false;
30
31 1
		if ( $settings === false ) {
32
			$settings = array_merge(
33
				self::getDefaultSettings(),
34
				$GLOBALS['egSemanticSignupSettings']
35
			);
36
		}
37
38 1
		return $settings;
39
	}
40
41
	public static function get( $settingName ) {
42
		$settings = self::getSettings();
43
		return array_key_exists( $settingName, $settings ) ? $settings[$settingName] : null;
44
	}
45
46
	public static function set( $key, $value ) {
47
		$settings = self::getSettings();
48
		$settings[ $key ] = $value;
49
	}
50
51
}
52