Settings::newFromGlobals()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace ParamProcessor;
4
5
/**
6
 * File defining the settings for the ParamProcessor extension.
7
 * More info can be found at https://www.mediawiki.org/wiki/Extension:Validator#Settings
8
 *
9
 * NOTICE:
10
 * Changing one of these settings can be done by assigning to $egValidatorSettings,
11
 * AFTER the inclusion of the extension itself.
12
 *
13
 * @deprecated since 1.7
14
 *
15
 * @licence GNU GPL v2+
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
final class Settings {
19
20
	/**
21
	 * Constructs a new instance of the settings object from global state.
22
	 *
23
	 * @since 1.0
24
	 *
25
	 * @param array $globalVariables
26
	 *
27
	 * @return Settings
28
	 */
29
	public static function newFromGlobals( array $globalVariables ) {
30
		return new self( $globalVariables['egValidatorSettings'] );
0 ignored issues
show
Deprecated Code introduced by
The class ParamProcessor\Settings has been deprecated with message: since 1.7

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
31
	}
32
33
	/**
34
	 * @since 1.0
35
	 *
36
	 * @var array
37
	 */
38
	private $settings;
39
40
	/**
41
	 * Constructor.
42
	 *
43
	 * @since 1.0
44
	 *
45
	 * @param array $settings
46
	 */
47 4
	public function __construct( array $settings ) {
48 4
		$this->settings = $settings;
49 4
	}
50
51
	/**
52
	 * Returns the setting with the provided name.
53
	 * The specified setting needs to exist.
54
	 *
55
	 * @since 1.0
56
	 *
57
	 * @param string $settingName
58
	 *
59
	 * @return mixed
60
	 */
61 3
	public function get( $settingName ) {
62 3
		return $this->settings[$settingName];
63
	}
64
65
}
66