Settings::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 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