Skip to content

Commit 98a796b

Browse files
committed
Add StatementByGuidMap::toArray
1 parent 2910a0f commit 98a796b

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/Statement/StatementByGuidMap.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,13 @@ public function getIterator() {
109109
return new ArrayIterator( $this->statements );
110110
}
111111

112+
/**
113+
* Returns the map in array form. The array keys are the GUIDs of their associated statement.
114+
*
115+
* @return Statement[]
116+
*/
117+
public function toArray() {
118+
return $this->statements;
119+
}
120+
112121
}

tests/unit/Statement/StatementByGuidMapTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,18 @@ public function testGivenStatementWithPresentGuid_addStatementReplacesThePresent
180180
$this->assertEquals( $statement2, $statements->getStatementByGuid( 'some guid' ) );
181181
}
182182

183+
public function testToArray() {
184+
$statement1 = $this->newStatement( 1, 'some guid' );
185+
$statement2 = $this->newStatement( 2, 'other guid' );
186+
187+
$statementMap = new StatementByGuidMap( array( $statement1, $statement2 ) );
188+
189+
$expectedStatements = array(
190+
'some guid' => $statement1,
191+
'other guid' => $statement2
192+
);
193+
194+
$this->assertEquals( $expectedStatements, $statementMap->toArray() );
195+
}
196+
183197
}

0 commit comments

Comments
 (0)