Completed
Branch master (0c9f05)
by
unknown
29:21
created

HTMLSelectNamespace::shouldInfuseOOUI()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * Wrapper for Html::namespaceSelector to use in HTMLForm
4
 */
5
class HTMLSelectNamespace extends HTMLFormField {
6
	public function __construct( $params ) {
7
		parent::__construct( $params );
8
9
		$this->mAllValue = array_key_exists( 'all', $params )
0 ignored issues
show
Bug introduced by
The property mAllValue does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
10
			? $params['all']
11
			: 'all';
12
13
	}
14
15
	function getInputHTML( $value ) {
16
		return Html::namespaceSelector(
17
			[
18
				'selected' => $value,
19
				'all' => $this->mAllValue
20
			], [
21
				'name' => $this->mName,
22
				'id' => $this->mID,
23
				'class' => 'namespaceselector',
24
			]
25
		);
26
	}
27
28
	public function getInputOOUI( $value ) {
29
		return new MediaWiki\Widget\NamespaceInputWidget( [
30
			'value' => $value,
31
			'name' => $this->mName,
32
			'id' => $this->mID,
33
			'includeAllValue' => $this->mAllValue,
34
		] );
35
	}
36
37
	protected function shouldInfuseOOUI() {
38
		return true;
39
	}
40
}
41