1 | <?php |
||
29 | class Statement implements Hashable, Comparable, PropertyIdProvider, FacetContainer { |
||
30 | |||
31 | /** |
||
32 | * Rank enum. Higher values are more preferred. |
||
33 | * |
||
34 | * @since 2.0 |
||
35 | */ |
||
36 | const RANK_PREFERRED = 2; |
||
37 | const RANK_NORMAL = 1; |
||
38 | const RANK_DEPRECATED = 0; |
||
39 | |||
40 | /** |
||
41 | * @var string|null |
||
42 | */ |
||
43 | private $guid = null; |
||
44 | |||
45 | /** |
||
46 | * @var Snak |
||
47 | */ |
||
48 | private $mainSnak; |
||
49 | |||
50 | /** |
||
51 | * The property value snaks making up the qualifiers for this statement. |
||
52 | * |
||
53 | * @var SnakList |
||
54 | */ |
||
55 | private $qualifiers; |
||
56 | |||
57 | /** |
||
58 | * @var ReferenceList |
||
59 | */ |
||
60 | private $references; |
||
61 | |||
62 | /** |
||
63 | * @var integer, element of the Statement::RANK_ enum |
||
64 | */ |
||
65 | private $rank = self::RANK_NORMAL; |
||
66 | |||
67 | /** |
||
68 | * @var FacetManager |
||
69 | */ |
||
70 | private $facetManager; |
||
71 | |||
72 | /** |
||
73 | * @since 2.0 |
||
74 | * |
||
75 | * @param Snak $mainSnak |
||
76 | * @param SnakList|null $qualifiers |
||
77 | * @param ReferenceList|null $references |
||
78 | * @param string|null $guid |
||
79 | */ |
||
80 | 23 | public function __construct( |
|
91 | |||
92 | /** |
||
93 | * Returns the GUID of this statement. |
||
94 | * |
||
95 | * @since 0.2 |
||
96 | * |
||
97 | * @return string|null |
||
98 | */ |
||
99 | 11 | public function getGuid() { |
|
102 | |||
103 | /** |
||
104 | * Sets the GUID of this statement. |
||
105 | * |
||
106 | * @since 0.2 |
||
107 | * |
||
108 | * @param string|null $guid |
||
109 | * |
||
110 | * @throws InvalidArgumentException |
||
111 | */ |
||
112 | 31 | public function setGuid( $guid ) { |
|
119 | |||
120 | /** |
||
121 | * Returns the main value snak of this statement. |
||
122 | * |
||
123 | * @since 0.1 |
||
124 | * |
||
125 | * @return Snak |
||
126 | */ |
||
127 | 9 | public function getMainSnak() { |
|
130 | |||
131 | /** |
||
132 | * Sets the main value snak of this statement. |
||
133 | * |
||
134 | * @since 0.1 |
||
135 | * |
||
136 | * @param Snak $mainSnak |
||
137 | */ |
||
138 | public function setMainSnak( Snak $mainSnak ) { |
||
141 | |||
142 | /** |
||
143 | * Returns the property value snaks making up the qualifiers for this statement. |
||
144 | * |
||
145 | * @since 0.1 |
||
146 | * |
||
147 | * @return SnakList |
||
148 | */ |
||
149 | 8 | public function getQualifiers() { |
|
152 | |||
153 | /** |
||
154 | * Sets the property value snaks making up the qualifiers for this statement. |
||
155 | * |
||
156 | * @since 0.1 |
||
157 | * |
||
158 | * @param SnakList $propertySnaks |
||
159 | */ |
||
160 | public function setQualifiers( SnakList $propertySnaks ) { |
||
163 | |||
164 | /** |
||
165 | * Returns the references attached to this statement. |
||
166 | * |
||
167 | * @since 0.1 |
||
168 | * |
||
169 | * @return ReferenceList |
||
170 | */ |
||
171 | 23 | public function getReferences() { |
|
174 | |||
175 | /** |
||
176 | * Sets the references attached to this statement. |
||
177 | * |
||
178 | * @since 0.1 |
||
179 | * |
||
180 | * @param ReferenceList $references |
||
181 | */ |
||
182 | 4 | public function setReferences( ReferenceList $references ) { |
|
185 | |||
186 | /** |
||
187 | * @since 2.0 |
||
188 | * |
||
189 | * @param Snak[]|Snak $snaks |
||
190 | * @param Snak [$snak2,...] |
||
191 | * |
||
192 | * @throws InvalidArgumentException |
||
193 | */ |
||
194 | 8 | public function addNewReference( $snaks = array() /*...*/ ) { |
|
201 | |||
202 | /** |
||
203 | * Sets the rank of the statement. |
||
204 | * The rank is an element of the Statement::RANK_ enum. |
||
205 | * |
||
206 | * @since 0.1 |
||
207 | * |
||
208 | * @param integer $rank |
||
209 | * @throws InvalidArgumentException |
||
210 | */ |
||
211 | 9 | public function setRank( $rank ) { |
|
220 | |||
221 | /** |
||
222 | * @since 0.1 |
||
223 | * |
||
224 | * @return integer |
||
225 | */ |
||
226 | 8 | public function getRank() { |
|
229 | |||
230 | /** |
||
231 | * @see Hashable::getHash |
||
232 | * |
||
233 | * @since 0.1 |
||
234 | * |
||
235 | * @return string |
||
236 | */ |
||
237 | 5 | public function getHash() { |
|
247 | |||
248 | /** |
||
249 | * Returns the id of the property of the main snak. |
||
250 | * Short for ->getMainSnak()->getPropertyId() |
||
251 | * |
||
252 | * @see PropertyIdProvider::getPropertyId |
||
253 | * |
||
254 | * @since 0.2 |
||
255 | * |
||
256 | * @return PropertyId |
||
257 | */ |
||
258 | 4 | public function getPropertyId() { |
|
261 | |||
262 | /** |
||
263 | * Returns a list of all Snaks on this statement. This includes the main snak and all snaks |
||
264 | * from qualifiers and references. |
||
265 | * |
||
266 | * This is a convenience method for use in code that needs to operate on all snaks, e.g. |
||
267 | * to find all referenced Entities. |
||
268 | * |
||
269 | * @return Snak[] |
||
270 | */ |
||
271 | 4 | public function getAllSnaks() { |
|
287 | |||
288 | /** |
||
289 | * @see Comparable::equals |
||
290 | * |
||
291 | * @since 0.7.4 |
||
292 | * |
||
293 | * @param mixed $target |
||
294 | * |
||
295 | * @return bool |
||
296 | */ |
||
297 | 12 | public function equals( $target ) { |
|
309 | |||
310 | /** |
||
311 | * @param string $name |
||
312 | * |
||
313 | * @return boolean |
||
314 | */ |
||
315 | 4 | public function hasFacet( $name ) { |
|
318 | |||
319 | /** |
||
320 | * @return string[] |
||
321 | */ |
||
322 | 4 | public function listFacets() { |
|
325 | |||
326 | /** |
||
327 | * @param string $name |
||
328 | * @param string|null $type The desired type |
||
329 | * |
||
330 | * @return object |
||
331 | */ |
||
332 | 8 | public function getFacet( $name, $type = null ) { |
|
339 | |||
340 | /** |
||
341 | * @param string $name |
||
342 | * @param object $facetObject |
||
343 | */ |
||
344 | 16 | public function addFacet( $name, $facetObject ) { |
|
351 | |||
352 | } |
||
353 |