Skip to content

Commit 81f68ed

Browse files
committed
Removed Claims::getByRank and Claims::getByRanks
1 parent 89a45f2 commit 81f68ed

3 files changed

Lines changed: 1 addition & 124 deletions

File tree

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Removed `ClaimList`
1111
* Removed `ClaimListAccess`
1212
* Removed `Claims::getBestClaims` (you can use `StatementList::getBestStatements` instead)
13+
* Removed `Claims::getByRank` and `Claims::getByRanks` (you can use `StatementList::getWithRank` instead)
1314

1415
## Version 2.6.0 (2015-03-08)
1516

src/Claim/Claims.php

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -376,51 +376,6 @@ public function isEmpty() {
376376
return !$this->getIterator()->valid();
377377
}
378378

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-
424379
/**
425380
* @see Comparable::equals
426381
*

tests/unit/Claim/ClaimsTest.php

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -542,85 +542,6 @@ public function testIsEmpty() {
542542
$this->assertTrue( $claims->isEmpty() );
543543
}
544544

545-
public function provideGetByRank() {
546-
$s1 = $this->makeStatement( new PropertyNoValueSnak( new PropertyId( 'P1' ) ) );
547-
$s1->setRank( Statement::RANK_DEPRECATED );
548-
549-
$s2 = $this->makeStatement( new PropertyNoValueSnak( new PropertyId( 'P2' ) ) );
550-
$s2->setRank( Statement::RANK_PREFERRED );
551-
552-
$s3 = $this->makeStatement( new PropertyNoValueSnak( new PropertyId( 'P3' ) ) );
553-
$s3->setRank( Statement::RANK_PREFERRED );
554-
555-
return array(
556-
// Empty yields empty
557-
array(
558-
new Claims(),
559-
Statement::RANK_NORMAL,
560-
new Claims()
561-
),
562-
// One statement with RANK_PREFERRED, so return it
563-
array(
564-
new Claims( array( $s2 ) ),
565-
Statement::RANK_PREFERRED,
566-
new Claims( array( $s2 ) ),
567-
),
568-
// s2 and s3 have RANK_PREFERRED, so return them
569-
array(
570-
new Claims( array( $s2, $s1, $s3 ) ),
571-
Statement::RANK_PREFERRED,
572-
new Claims( array( $s2, $s3 ) ),
573-
),
574-
);
575-
}
576-
577-
/**
578-
* @dataProvider provideGetByRank
579-
*/
580-
public function testGetByRank( Claims $input, $rank, $expected ) {
581-
$this->assertEquals( $input->getByRank( $rank ), $expected );
582-
}
583-
584-
public function provideGetByRanks() {
585-
$s1 = $this->makeStatement( new PropertyNoValueSnak( new PropertyId( 'P1' ) ) );
586-
$s1->setRank( Statement::RANK_NORMAL );
587-
588-
$s2 = $this->makeStatement( new PropertyNoValueSnak( new PropertyId( 'P2' ) ) );
589-
$s2->setRank( Statement::RANK_PREFERRED );
590-
591-
$ret = array(
592-
// s1 has RANK_NORMAL, thus doesn't match
593-
array(
594-
new Claims( array( $s2, $s1 ) ),
595-
array( Statement::RANK_PREFERRED, Statement::RANK_DEPRECATED ),
596-
new Claims( array( $s2 ) ),
597-
),
598-
// s2 has RANK_PREFERRED and s1 has RANK_NORMAL, so return them
599-
array(
600-
new Claims( array( $s2, $s1 ) ),
601-
array( Statement::RANK_PREFERRED, Statement::RANK_NORMAL ),
602-
new Claims( array( $s2, $s1 ) ),
603-
)
604-
);
605-
606-
// This function acts very similar to Claims::getByRank, so that we
607-
// can reuse the test cases
608-
$ret = array_merge( $this->provideGetByRank(), $ret );
609-
610-
return $ret;
611-
}
612-
613-
/**
614-
* @dataProvider provideGetByRanks
615-
*/
616-
public function testGetByRanks( Claims $input, $ranks, $expected ) {
617-
if ( !is_array( $ranks ) ) {
618-
$ranks = array( $ranks );
619-
}
620-
621-
$this->assertEquals( $input->getByRanks( $ranks ), $expected );
622-
}
623-
624545
public function testEmptyListEqualsEmptyList() {
625546
$list = new Claims( array() );
626547
$this->assertTrue( $list->equals( clone $list ) );

0 commit comments

Comments
 (0)