summaryrefslogtreecommitdiff
path: root/www/wiki/includes/search/SearchNearMatchResultSet.php
blob: 31417974d98f53f5af205ebbb14db58214f9d659 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?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;
	}
}