Settings   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 50
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get() 0 3 1
A newFromGlobals() 0 5 1
1
<?php
2
3
namespace SubPageList;
4
5
/**
6
 * Container for the settings contained by this extension.
7
 *
8
 * @since 1.0
9
 *
10
 * @licence GNU GPL v2+
11
 * @author Jeroen De Dauw < [email protected] >
12
 */
13
class Settings {
14
15
	/**
16
	 * Constructs a new instance of the settings object from global state.
17
	 *
18
	 * @since 1.0
19
	 *
20
	 * @param array $globalVariables
21
	 *
22
	 * @return Settings
23
	 */
24 24
	public static function newFromGlobals( array $globalVariables ) {
25 24
		return new self( [
26 24
			self::AUTO_REFRESH => $globalVariables['egSPLAutorefresh'],
27
		] );
28
	}
29
30
	const AUTO_REFRESH = 'autorefresh';
31
32
	/**
33
	 * @var array
34
	 */
35
	private $settings;
36
37
	/**
38
	 * Constructor.
39
	 *
40
	 * @since 1.0
41
	 *
42
	 * @param array $settings
43
	 */
44 28
	public function __construct( array $settings ) {
45 28
		$this->settings = $settings;
46 28
	}
47
48
	/**
49
	 * Returns the setting with the provided name.
50
	 * The specified setting needs to exist.
51
	 *
52
	 * @since 1.0
53
	 *
54
	 * @param string $settingName
55
	 *
56
	 * @return mixed
57
	 */
58 7
	public function get( $settingName ) {
59 7
		return $this->settings[$settingName];
60
	}
61
62
}
63