|
22 | 22 | * @author Daniel Kinzler |
23 | 23 | * @author H. Snater < mediawiki@snater.com > |
24 | 24 | */ |
25 | | -class Claims extends ArrayObject implements Hashable, Comparable { |
| 25 | +class Claims extends ArrayObject implements Hashable { |
26 | 26 |
|
27 | 27 | /** |
28 | 28 | * @see GenericArrayObject::__construct |
@@ -279,76 +279,6 @@ public function offsetUnset( $guid ) { |
279 | 279 | parent::offsetUnset( $key ); |
280 | 280 | } |
281 | 281 |
|
282 | | - /** |
283 | | - * Get array of Claim guids |
284 | | - * |
285 | | - * @since 0.4 |
286 | | - * |
287 | | - * @return string[] |
288 | | - */ |
289 | | - public function getGuids() { |
290 | | - return array_map( function ( Claim $claim ) { |
291 | | - return $claim->getGuid(); |
292 | | - }, iterator_to_array( $this ) ); |
293 | | - } |
294 | | - |
295 | | - /** |
296 | | - * Returns the claims for the given property. |
297 | | - * |
298 | | - * @since 0.4 |
299 | | - * |
300 | | - * @param PropertyId $propertyId |
301 | | - * |
302 | | - * @return Claims |
303 | | - */ |
304 | | - public function getClaimsForProperty( PropertyId $propertyId ) { |
305 | | - $byPropertyIdGrouper = new ByPropertyIdGrouper( $this ); |
306 | | - |
307 | | - if ( !$byPropertyIdGrouper->hasPropertyId( $propertyId ) ) { |
308 | | - return new self(); |
309 | | - } |
310 | | - |
311 | | - return new self( $byPropertyIdGrouper->getByPropertyId( $propertyId ) ); |
312 | | - } |
313 | | - |
314 | | - /** |
315 | | - * Returns the main Snaks of the claims in this list. |
316 | | - * |
317 | | - * @since 0.4 |
318 | | - * |
319 | | - * @return Snak[] |
320 | | - */ |
321 | | - public function getMainSnaks() { |
322 | | - $snaks = array(); |
323 | | - |
324 | | - /* @var Claim $claim */ |
325 | | - foreach ( $this as $claim ) { |
326 | | - $guid = $claim->getGuid(); |
327 | | - $snaks[$guid] = $claim->getMainSnak(); |
328 | | - } |
329 | | - |
330 | | - return $snaks; |
331 | | - } |
332 | | - |
333 | | - /** |
334 | | - * Returns a map from GUIDs to claim hashes. |
335 | | - * |
336 | | - * @since 0.4 |
337 | | - * |
338 | | - * @return string[] |
339 | | - */ |
340 | | - public function getHashes() { |
341 | | - $snaks = array(); |
342 | | - |
343 | | - /* @var Claim $claim */ |
344 | | - foreach ( $this as $claim ) { |
345 | | - $guid = $claim->getGuid(); |
346 | | - $snaks[$guid] = $claim->getHash(); |
347 | | - } |
348 | | - |
349 | | - return $snaks; |
350 | | - } |
351 | | - |
352 | 282 | /** |
353 | 283 | * Returns a hash based on the value of the object. |
354 | 284 | * The hash is based on the hashes of the claims contained, |
@@ -376,107 +306,4 @@ public function isEmpty() { |
376 | 306 | return !$this->getIterator()->valid(); |
377 | 307 | } |
378 | 308 |
|
379 | | - /** |
380 | | - * Returns a new instance only containing the claims with the given rank. |
381 | | - * |
382 | | - * @since 0.7 |
383 | | - * |
384 | | - * @param int $rank |
385 | | - * |
386 | | - * @return Claims |
387 | | - */ |
388 | | - public function getByRank( $rank ) { |
389 | | - $claims = new self(); |
390 | | - |
391 | | - /* @var Claim $claim */ |
392 | | - foreach ( $this as $claim ) { |
393 | | - if ( $claim->getRank() === $rank ) { |
394 | | - $claims[] = $claim; |
395 | | - } |
396 | | - } |
397 | | - |
398 | | - return $claims; |
399 | | - } |
400 | | - |
401 | | - /** |
402 | | - * Returns a new instance only containing the claims with the given ranks. |
403 | | - * |
404 | | - * @since 0.7.2 |
405 | | - * |
406 | | - * @param int[] $ranks |
407 | | - * |
408 | | - * @return Claims |
409 | | - */ |
410 | | - public function getByRanks( array $ranks ) { |
411 | | - $ranks = array_flip( $ranks ); |
412 | | - $claims = new self(); |
413 | | - |
414 | | - /* @var Claim $claim */ |
415 | | - foreach ( $this as $claim ) { |
416 | | - if ( isset( $ranks[$claim->getRank()] ) ) { |
417 | | - $claims[] = $claim; |
418 | | - } |
419 | | - } |
420 | | - |
421 | | - return $claims; |
422 | | - } |
423 | | - |
424 | | - /** |
425 | | - * Returns a new instance only containing the best claims (these are the highest |
426 | | - * ranked claims, but never deprecated ones). This implementation ignores the properties |
427 | | - * so you probably want to call Claims::getClaimsForProperty first or use |
428 | | - * StatementList::getBestStatementPerProperty instead. |
429 | | - * |
430 | | - * @see Claims::getClaimsForProperty |
431 | | - * @see StatementList::getBestStatementPerProperty |
432 | | - * |
433 | | - * @since 0.7 |
434 | | - * |
435 | | - * @return Claims |
436 | | - */ |
437 | | - public function getBestClaims() { |
438 | | - $rank = Statement::RANK_PREFERRED; |
439 | | - |
440 | | - do { |
441 | | - $claims = $this->getByRank( $rank ); |
442 | | - $rank--; |
443 | | - } while ( $claims->isEmpty() && $rank > Statement::RANK_DEPRECATED ); |
444 | | - |
445 | | - return $claims; |
446 | | - } |
447 | | - |
448 | | - /** |
449 | | - * @see Comparable::equals |
450 | | - * |
451 | | - * @since 0.7.4 |
452 | | - * |
453 | | - * @param mixed $target |
454 | | - * |
455 | | - * @return bool |
456 | | - */ |
457 | | - public function equals( $target ) { |
458 | | - if ( $this === $target ) { |
459 | | - return true; |
460 | | - } |
461 | | - |
462 | | - if ( !( $target instanceof self ) |
463 | | - || $this->count() !== $target->count() |
464 | | - ) { |
465 | | - return false; |
466 | | - } |
467 | | - |
468 | | - foreach ( $this as $claim ) { |
469 | | - if ( !$target->hasExactClaim( $claim ) ) { |
470 | | - return false; |
471 | | - } |
472 | | - } |
473 | | - |
474 | | - return true; |
475 | | - } |
476 | | - |
477 | | - private function hasExactClaim( Claim $claim ) { |
478 | | - return $this->hasClaim( $claim ) |
479 | | - && $this->getClaimWithGuid( $claim->getGuid() )->equals( $claim ); |
480 | | - } |
481 | | - |
482 | 309 | } |
0 commit comments