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
|
|
|
|