1 | <?php |
||
22 | class Statement implements PropertyIdProvider { |
||
23 | |||
24 | /** |
||
25 | * Rank enum. Higher values are more preferred. |
||
26 | * |
||
27 | * @since 2.0 |
||
28 | */ |
||
29 | public const RANK_PREFERRED = 2; |
||
30 | public const RANK_NORMAL = 1; |
||
31 | public const RANK_DEPRECATED = 0; |
||
32 | |||
33 | /** |
||
34 | * @var string|null |
||
35 | */ |
||
36 | private $guid = null; |
||
37 | |||
38 | /** |
||
39 | * @var Snak |
||
40 | */ |
||
41 | private $mainSnak; |
||
42 | |||
43 | /** |
||
44 | * The property value snaks making up the qualifiers for this statement. |
||
45 | * |
||
46 | * @var SnakList |
||
47 | */ |
||
48 | private $qualifiers; |
||
49 | |||
50 | /** |
||
51 | * @var ReferenceList |
||
52 | */ |
||
53 | private $references; |
||
54 | |||
55 | /** |
||
56 | * @var int element of the Statement::RANK_ enum |
||
57 | */ |
||
58 | private $rank = self::RANK_NORMAL; |
||
59 | |||
60 | /** |
||
61 | * @since 2.0 |
||
62 | * |
||
63 | * @param Snak $mainSnak |
||
64 | * @param SnakList|null $qualifiers |
||
65 | * @param ReferenceList|null $references |
||
66 | * @param string|null $guid |
||
67 | */ |
||
68 | public function __construct( |
||
79 | |||
80 | 23 | /** |
|
81 | * @since 0.2 |
||
82 | * |
||
83 | * @return string|null |
||
84 | */ |
||
85 | public function getGuid() { |
||
88 | 23 | ||
89 | 23 | /** |
|
90 | 19 | * Sets the GUID of this statement. |
|
91 | * |
||
92 | * @since 0.2 |
||
93 | * |
||
94 | * @param string|null $guid |
||
95 | * |
||
96 | * @throws InvalidArgumentException |
||
97 | */ |
||
98 | public function setGuid( $guid ) { |
||
105 | |||
106 | /** |
||
107 | * Returns the main value snak of this statement. |
||
108 | * |
||
109 | * @since 0.1 |
||
110 | * |
||
111 | * @return Snak |
||
112 | 31 | */ |
|
113 | 31 | public function getMainSnak() { |
|
116 | |||
117 | 27 | /** |
|
118 | 27 | * Sets the main value snak of this statement. |
|
119 | * |
||
120 | * @since 0.1 |
||
121 | * |
||
122 | * @param Snak $mainSnak |
||
123 | */ |
||
124 | public function setMainSnak( Snak $mainSnak ) { |
||
127 | 9 | ||
128 | 9 | /** |
|
129 | * Returns the property value snaks making up the qualifiers for this statement. |
||
130 | * |
||
131 | * @since 0.1 |
||
132 | * |
||
133 | * @return SnakList |
||
134 | */ |
||
135 | public function getQualifiers() { |
||
138 | |||
139 | /** |
||
140 | * Sets the property value snaks making up the qualifiers for this statement. |
||
141 | * |
||
142 | * @since 0.1 |
||
143 | * |
||
144 | * @param SnakList $propertySnaks |
||
145 | */ |
||
146 | public function setQualifiers( SnakList $propertySnaks ) { |
||
149 | 8 | ||
150 | 8 | /** |
|
151 | * Returns the references attached to this statement. |
||
152 | * |
||
153 | * @since 0.1 |
||
154 | * |
||
155 | * @return ReferenceList |
||
156 | */ |
||
157 | public function getReferences() { |
||
160 | |||
161 | /** |
||
162 | * Sets the references attached to this statement. |
||
163 | * |
||
164 | * @since 0.1 |
||
165 | * |
||
166 | * @param ReferenceList $references |
||
167 | */ |
||
168 | public function setReferences( ReferenceList $references ) { |
||
171 | 23 | ||
172 | 23 | /** |
|
173 | * @since 2.0 |
||
174 | * |
||
175 | * @param Snak ...$snaks |
||
176 | * (passing a single Snak[] is still supported but deprecated) |
||
177 | * |
||
178 | * @throws InvalidArgumentException |
||
179 | */ |
||
180 | public function addNewReference( ...$snaks ) { |
||
188 | |||
189 | /** |
||
190 | * Sets the rank of the statement. |
||
191 | * The rank is an element of the Statement::RANK_ enum. |
||
192 | * |
||
193 | * @since 0.1 |
||
194 | 8 | * |
|
195 | 8 | * @param integer $rank |
|
196 | 4 | * @throws InvalidArgumentException |
|
197 | 4 | */ |
|
198 | public function setRank( $rank ) { |
||
207 | |||
208 | /** |
||
209 | * @since 0.1 |
||
210 | * |
||
211 | 9 | * @return integer |
|
212 | 9 | */ |
|
213 | public function getRank() { |
||
216 | |||
217 | /** |
||
218 | 5 | * @since 0.1 |
|
219 | 5 | * |
|
220 | * @return string |
||
221 | */ |
||
222 | public function getHash() { |
||
232 | |||
233 | /** |
||
234 | * Returns the id of the property of the main snak. |
||
235 | * Short for ->getMainSnak()->getPropertyId() |
||
236 | * |
||
237 | 5 | * @see PropertyIdProvider::getPropertyId |
|
238 | 5 | * |
|
239 | 5 | * @since 0.2 |
|
240 | * |
||
241 | 5 | * @return PropertyId |
|
242 | 5 | */ |
|
243 | 5 | public function getPropertyId() { |
|
246 | |||
247 | /** |
||
248 | * Returns a list of all Snaks on this statement. This includes the main snak and all snaks |
||
249 | * from qualifiers and references. |
||
250 | * |
||
251 | * This is a convenience method for use in code that needs to operate on all snaks, e.g. |
||
252 | * to find all referenced Entities. |
||
253 | * |
||
254 | * @return Snak[] |
||
255 | */ |
||
256 | public function getAllSnaks() { |
||
272 | 4 | ||
273 | /** |
||
274 | 4 | * |
|
275 | * @since 0.7.4 |
||
276 | 4 | * |
|
277 | * @param mixed $target |
||
278 | * |
||
279 | 4 | * @return bool |
|
280 | 1 | */ |
|
281 | 1 | public function equals( $target ) { |
|
293 | |||
294 | /** |
||
295 | * @see http://php.net/manual/en/language.oop5.cloning.php |
||
296 | * |
||
297 | 12 | * @since 5.1 |
|
298 | 12 | */ |
|
299 | 1 | public function __clone() { |
|
303 | 12 | ||
304 | } |
||
305 |