NamespaceInfo   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 115
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 96.67%

Importance

Changes 0
Metric Value
wmc 14
lcom 0
cbo 0
dl 0
loc 115
ccs 29
cts 30
cp 0.9667
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 28 8
A getId() 0 3 1
A getCanonicalName() 0 3 1
A getLocalName() 0 3 1
A getCaseHandling() 0 3 1
A getDefaultContentModel() 0 3 1
A getAliases() 0 3 1
1
<?php
2
3
namespace Mediawiki\DataModel;
4
5
/**
6
 * Class representing metadata about a MediaWiki namespace
7
 *
8
 * @author gbirke
9
 */
10
class NamespaceInfo {
11
	/**
12
	 * @var int
13
	 */
14
	private $id;
15
16
	/**
17
	 * @var string
18
	 */
19
	private $canonicalName;
20
21
	/**
22
	 * @var string
23
	 */
24
	private $localName;
25
26
	/**
27
	 * @var string
28
	 */
29
	private $caseHandling;
30
31
	/**
32
	 * @var string
33
	 */
34
	private $defaultContentModel;
35
36
	/**
37
	 * @var array
38
	 */
39
	private $aliases;
40
41
	/**
42
	 * NamespaceInfo constructor.
43
	 *
44
	 * @param int $id
45
	 * @param string $canonicalName
46
	 * @param string $localName
47
	 * @param string $caseHandling
48
	 * @param string|null $defaultContentModel
49
	 * @param array $aliases
50
	 *
51
	 * @throws InvalidArgumentException
52
	 */
53 13
	public function __construct( $id, $canonicalName, $localName, $caseHandling, $defaultContentModel = null, $aliases = [] ) {
54
		if ( !is_int( $id ) ) {
55 13
			throw new \InvalidArgumentException( '$id must be an integer' );
56 2
		}
57
		if ( !is_string( $canonicalName ) ) {
58 11
			throw new \InvalidArgumentException( '$canonicalName must be a string' );
59 2
		}
60
		if ( !is_string( $localName ) ) {
61 9
			throw new \InvalidArgumentException( '$localName must be a string' );
62 1
		}
63
		if ( !is_string( $caseHandling ) ) {
64 8
			throw new \InvalidArgumentException( '$caseHandling must be a string' );
65
		}
66
		if ( $defaultContentModel !== null && !is_string( $defaultContentModel ) ) {
67 8
			throw new \InvalidArgumentException( '$canonicalName must be a string' );
68 2
		}
69
70
		if ( !is_array( $aliases ) ) {
71 6
			throw new \InvalidArgumentException( '$aliases must be an array' );
72 1
		}
73
74
		$this->id = $id;
75 5
		$this->canonicalName = $canonicalName;
76 5
		$this->localName = $localName;
77 5
		$this->caseHandling = $caseHandling;
78 5
		$this->defaultContentModel = $defaultContentModel;
79 5
		$this->aliases = $aliases;
80 5
	}
81 5
82
	/**
83
	 * @return int
84
	 */
85
	public function getId() {
86 5
		return $this->id;
87
	}
88 5
89
	/**
90
	 * @return string
91
	 */
92
	public function getCanonicalName() {
93
		return $this->canonicalName;
94 5
	}
95
96 5
	/**
97
	 * @return string
98
	 */
99
	public function getLocalName() {
100
		return $this->localName;
101
	}
102 5
103
	/**
104 5
	 * @return string
105
	 */
106
	public function getCaseHandling() {
107
		return $this->caseHandling;
108
	}
109
110 5
	/**
111
	 * @return string
112 5
	 */
113
	public function getDefaultContentModel() {
114
		return $this->defaultContentModel;
115
	}
116
117
	/**
118 5
	 * @return array
119
	 */
120 5
	public function getAliases() {
121
		return $this->aliases;
122
	}
123
124
}
125