1 | <?php |
||
23 | class Item implements EntityDocument, FingerprintHolder, StatementListHolder { |
||
24 | |||
25 | const ENTITY_TYPE = 'item'; |
||
26 | |||
27 | /** |
||
28 | * @var ItemId|null |
||
29 | */ |
||
30 | private $id; |
||
31 | |||
32 | /** |
||
33 | * @var Fingerprint |
||
34 | */ |
||
35 | private $fingerprint; |
||
36 | |||
37 | /** |
||
38 | * @var SiteLinkList |
||
39 | */ |
||
40 | private $siteLinks; |
||
41 | |||
42 | /** |
||
43 | * @var StatementList |
||
44 | */ |
||
45 | private $statements; |
||
46 | |||
47 | /** |
||
48 | * @since 1.0 |
||
49 | * |
||
50 | * @param ItemId|null $id |
||
51 | * @param Fingerprint|null $fingerprint |
||
52 | * @param SiteLinkList|null $siteLinks |
||
53 | * @param StatementList|null $statements |
||
54 | */ |
||
55 | public function __construct( |
||
66 | 81 | ||
67 | /** |
||
68 | * Returns the id of the entity or null if it does not have one. |
||
69 | * |
||
70 | * @since 0.1 return type changed in 0.3 |
||
71 | * |
||
72 | * @return ItemId|null |
||
73 | */ |
||
74 | public function getId() { |
||
75 | 12 | return $this->id; |
|
76 | 12 | } |
|
77 | |||
78 | /** |
||
79 | * Can be integer since 0.1. |
||
80 | * Can be ItemId since 0.5. |
||
81 | * Can be null since 1.0. |
||
82 | * |
||
83 | * @param ItemId|int|null $id |
||
84 | * |
||
85 | * @throws InvalidArgumentException |
||
86 | */ |
||
87 | public function setId( $id ) { |
||
97 | 2 | ||
98 | /** |
||
99 | * @since 0.7.3 |
||
100 | * |
||
101 | * @return Fingerprint |
||
102 | */ |
||
103 | public function getFingerprint() { |
||
104 | 58 | return $this->fingerprint; |
|
105 | 58 | } |
|
106 | |||
107 | /** |
||
108 | * @since 0.7.3 |
||
109 | * |
||
110 | * @param Fingerprint $fingerprint |
||
111 | */ |
||
112 | public function setFingerprint( Fingerprint $fingerprint ) { |
||
113 | 3 | $this->fingerprint = $fingerprint; |
|
114 | 3 | } |
|
115 | 3 | ||
116 | /** |
||
117 | * @param string $languageCode |
||
118 | * @param string $value |
||
119 | * |
||
120 | * @throws InvalidArgumentException |
||
121 | */ |
||
122 | public function setLabel( $languageCode, $value ) { |
||
125 | 12 | ||
126 | /** |
||
127 | * @param string $languageCode |
||
128 | * @param string $value |
||
129 | * |
||
130 | * @throws InvalidArgumentException |
||
131 | */ |
||
132 | public function setDescription( $languageCode, $value ) { |
||
135 | 11 | ||
136 | /** |
||
137 | * @param string $languageCode |
||
138 | * @param string[] $aliases |
||
139 | * |
||
140 | * @throws InvalidArgumentException |
||
141 | */ |
||
142 | public function setAliases( $languageCode, array $aliases ) { |
||
145 | 31 | ||
146 | /** |
||
147 | * @since 0.8 |
||
148 | * |
||
149 | * @return SiteLinkList |
||
150 | */ |
||
151 | public function getSiteLinkList() { |
||
154 | |||
155 | /** |
||
156 | * @since 0.8 |
||
157 | * |
||
158 | * @param SiteLinkList $siteLinks |
||
159 | */ |
||
160 | public function setSiteLinkList( SiteLinkList $siteLinks ) { |
||
163 | |||
164 | /** |
||
165 | * Adds a site link to the list of site links. |
||
166 | * If there already is a site link with the site id of the provided site link, |
||
167 | * then that one will be overridden by the provided one. |
||
168 | * |
||
169 | * @deprecated since 0.8, use getSiteLinkList()->addSiteLink() instead. |
||
170 | * @since 0.6 |
||
171 | * |
||
172 | * @param SiteLink $siteLink |
||
173 | */ |
||
174 | public function addSiteLink( SiteLink $siteLink ) { |
||
181 | 1 | ||
182 | /** |
||
183 | * Removes the sitelink with specified site ID if the Item has such a sitelink. |
||
184 | * |
||
185 | * @deprecated since 0.8, use getSiteLinkList()->removeLinkWithSiteId() instead. |
||
186 | * @since 0.1 |
||
187 | * |
||
188 | * @param string $siteId the target site's id |
||
189 | */ |
||
190 | public function removeSiteLink( $siteId ) { |
||
193 | |||
194 | /** |
||
195 | * @deprecated since 0.8, use getSiteLinkList() instead, |
||
196 | * @since 0.6 |
||
197 | * |
||
198 | * @return SiteLink[] |
||
199 | */ |
||
200 | public function getSiteLinks() { |
||
203 | |||
204 | /** |
||
205 | * @deprecated since 0.8, use getSiteLinkList()->getBySiteId() instead. |
||
206 | * @since 0.6 |
||
207 | * |
||
208 | * @param string $siteId |
||
209 | * |
||
210 | * @return SiteLink |
||
211 | * @throws OutOfBoundsException |
||
212 | */ |
||
213 | public function getSiteLink( $siteId ) { |
||
216 | |||
217 | /** |
||
218 | * @deprecated since 0.8, use getSiteLinkList()->hasLinkWithSiteId() instead. |
||
219 | * @since 0.4 |
||
220 | * |
||
221 | * @param string $siteId |
||
222 | * |
||
223 | * @return bool |
||
224 | */ |
||
225 | public function hasLinkToSite( $siteId ) { |
||
228 | |||
229 | /** |
||
230 | * @deprecated since 0.8, use getSiteLinkList()->isEmpty() instead. |
||
231 | * @since 0.5 |
||
232 | * |
||
233 | * @return bool |
||
234 | */ |
||
235 | public function hasSiteLinks() { |
||
238 | |||
239 | /** |
||
240 | * @deprecated since 2.5, use new Item() instead. |
||
241 | * |
||
242 | * @return self |
||
243 | */ |
||
244 | public static function newEmpty() { |
||
247 | |||
248 | /** |
||
249 | * @see Entity::getType |
||
250 | * |
||
251 | * @since 0.1 |
||
252 | * |
||
253 | * @return string Returns the entity type "item". |
||
254 | */ |
||
255 | public function getType() { |
||
258 | |||
259 | /** |
||
260 | * Returns if the Item has no content. |
||
261 | * Having an id set does not count as having content. |
||
262 | * |
||
263 | * @since 0.1 |
||
264 | * |
||
265 | * @return bool |
||
266 | */ |
||
267 | public function isEmpty() { |
||
272 | |||
273 | /** |
||
274 | * Removes all content from the Item. |
||
275 | * The id is not part of the content. |
||
276 | * |
||
277 | * @since 0.1 |
||
278 | */ |
||
279 | public function clear() { |
||
284 | 2 | ||
285 | /** |
||
286 | * @since 1.0 |
||
287 | * |
||
288 | * @return StatementList |
||
289 | */ |
||
290 | public function getStatements() { |
||
293 | |||
294 | /** |
||
295 | * @since 1.0 |
||
296 | * |
||
297 | * @param StatementList $statements |
||
298 | */ |
||
299 | public function setStatements( StatementList $statements ) { |
||
302 | 1 | ||
303 | /** |
||
304 | * @see EntityDocument::equals |
||
305 | * |
||
306 | * @since 0.1 |
||
307 | * |
||
308 | * @param mixed $target |
||
309 | 4 | * |
|
310 | 4 | * @return bool |
|
311 | */ |
||
312 | public function equals( $target ) { |
||
322 | |||
323 | /** |
||
324 | * @see EntityDocument::copy |
||
325 | * |
||
326 | * @since 0.1 |
||
327 | * |
||
328 | * @return self |
||
329 | */ |
||
330 | public function copy() { |
||
333 | |||
334 | } |
||
335 |