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