Skip to content

Commit 02aacff

Browse files
committed
Remove Claims::indexOf
1 parent 074812c commit 02aacff

3 files changed

Lines changed: 1 addition & 48 deletions

File tree

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* Removed `Claims::equals` (and `Claims` no longer implements `Comparable`)
2020
* Removed `Claims::getHash` (and `Claims` no longer implements `Hashable`)
2121
* Removed `Claims::isEmpty` (you can use `StatementList::isEmpty` instead)
22+
* Removed `Claims::indexOf` and added `StatementList::getIndexByGuid`
2223

2324
## Version 2.6.0 (2015-03-08)
2425

src/Claim/Claims.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,30 +135,6 @@ public function hasClaim( Claim $claim ) {
135135
return $this->offsetExists( $key );
136136
}
137137

138-
/**
139-
* @since 0.5
140-
*
141-
* @param Claim $claim
142-
*
143-
* @return int|bool
144-
*/
145-
public function indexOf( Claim $claim ) {
146-
$guid = $claim->getGuid();
147-
$index = 0;
148-
149-
/**
150-
* @var Claim $claimObject
151-
*/
152-
foreach ( $this as $claimObject ) {
153-
if ( $claimObject->getGuid() === $guid ) {
154-
return $index;
155-
}
156-
$index++;
157-
}
158-
159-
return false;
160-
}
161-
162138
/**
163139
* @since 0.1
164140
*

tests/unit/Claim/ClaimsTest.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -237,38 +237,14 @@ public function testAddClaim() {
237237
// Insert claim at the beginning:
238238
$claim3 = $this->makeClaim( new PropertyNoValueSnak( new PropertyId( 'P17' ) ) );
239239
$claims->addClaim( $claim3, 0 );
240-
$this->assertEquals( 0, $claims->indexOf( $claim3 ), 'Inserting claim at the beginning failed' );
241240

242241
// Insert claim at another index:
243242
$claim4 = $this->makeClaim( new PropertyNoValueSnak( new PropertyId( 'P18' ) ) );
244243
$claims->addClaim( $claim4, 1 );
245-
$this->assertEquals( 1, $claims->indexOf( $claim4 ), 'Inserting claim at index 1 failed' );
246244

247245
// Insert claim with an index out of bounds:
248246
$claim5 = $this->makeClaim( new PropertyNoValueSnak( new PropertyId( 'P19' ) ) );
249247
$claims->addClaim( $claim5, 99999 );
250-
$this->assertEquals( 4, $claims->indexOf( $claim5 ), 'Appending claim by specifying an index out of bounds failed' );
251-
}
252-
253-
public function testIndexOf() {
254-
$claims = new Claims();
255-
$claimArray = array(
256-
$this->makeClaim( new PropertyNoValueSnak( new PropertyId( 'P1' ) ) ),
257-
$this->makeClaim( new PropertyNoValueSnak( new PropertyId( 'P2' ) ) ),
258-
$this->makeClaim( new PropertyNoValueSnak( new PropertyId( 'P3' ) ) ),
259-
);
260-
$excludedClaim = $this->makeClaim( new PropertyNoValueSnak( new PropertyId( 'P99' ) ) );
261-
262-
foreach( $claimArray as $claim ) {
263-
$claims->addClaim( $claim );
264-
}
265-
266-
$this->assertFalse( $claims->indexOf( $excludedClaim ) );
267-
268-
$i = 0;
269-
foreach( $claimArray as $claim ) {
270-
$this->assertEquals( $i++, $claims->indexOf( $claim ) );
271-
}
272248
}
273249

274250
public function testAppend() {

0 commit comments

Comments
 (0)