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