wiki.techinc.nl/includes/search/SearchNearMatchResultSet.php
Stanislav Malyshev 7e18cfc3b5 Infrastructure for augmenting search results
Bug: T117493
Change-Id: Ia5413a7846cc961026a2dc3542b619493bc76a23
2016-09-15 15:44:03 -07:00

30 lines
593 B
PHP

<?php
/**
* A SearchResultSet wrapper for SearchNearMatcher
*/
class SearchNearMatchResultSet extends SearchResultSet {
private $fetched = false;
/**
* @param Title|null $match Title if matched, else null
*/
public function __construct( $match ) {
$this->result = $match;
}
public function numRows() {
return $this->result ? 1 : 0;
}
public function next() {
if ( $this->fetched || !$this->result ) {
return false;
}
$this->fetched = true;
return SearchResult::newFromTitle( $this->result, $this );
}
public function rewind() {
$this->fetched = false;
}
}