Completed
Branch master (86dc85)
by
unknown
23:45
created

SearchNearMatchResultSet   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 26
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A numRows() 0 3 2
A next() 0 7 3
A rewind() 0 3 1
1
<?php
2
/**
3
 * A SearchResultSet wrapper for SearchEngine::getNearMatch
4
 */
5
class SearchNearMatchResultSet extends SearchResultSet {
6
	private $fetched = false;
7
8
	/**
9
	 * @param Title|null $match Title if matched, else null
10
	 */
11
	public function __construct( $match ) {
12
		$this->result = $match;
0 ignored issues
show
Bug introduced by
The property result does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
13
	}
14
15
	public function numRows() {
16
		return $this->result ? 1 : 0;
17
	}
18
19
	public function next() {
20
		if ( $this->fetched || !$this->result ) {
21
			return false;
22
		}
23
		$this->fetched = true;
24
		return SearchResult::newFromTitle( $this->result );
25
	}
26
27
	public function rewind() {
28
		$this->fetched = false;
29
	}
30
}
31