for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SIL\Search;
use SearchResult;
use SearchResultSet;
use Title;
/**
* @license GNU GPL v2+
* @since 1.0
*
* @author mwjames
*/
class MappedSearchResultSet extends SearchResultSet {
* @var SearchResult[]
private $searchMatches = [];
* @var string[]
private $termMatches;
* @var integer
private $count;
* @param SearchResult[] $searchMatches
* @param array $termMatches
* @param integer $count
public function __construct( $searchMatches, $termMatches, $count = 0 ) {
$this->searchMatches = $searchMatches;
$this->termMatches = $termMatches;
$this->count = $count;
}
* @return SearchResult|boolean
public function next() {
if ( $this->searchMatches === false || $this->searchMatches === [] ) {
return false;
if ( ( list( $key, $match ) = each( $this->searchMatches ) ) !== false ) {
if ( $match instanceOf SearchResult ) {
return $match;
if ( $match instanceOf Title ) {
return SearchResult::newFromTitle( $match );
* Return number of rows included in this result set.
* @return int|void
public function numRows() {
return count( $this->searchMatches );
* Return true if results are included in this result set.
* @return bool
public function hasResults() {
return $this->numRows() > 0;
* @return integer
public function getTotalHits() {
return $this->count;
* @return string[]
public function termMatches() {
return $this->termMatches;