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

HTMLSelectNamespace   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 36
rs 10
c 1
b 0
f 0
wmc 5
lcom 1
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getInputHTML() 0 12 1
A getInputOOUI() 0 8 1
A shouldInfuseOOUI() 0 3 1
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