Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
PerRowAugmentor | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
augmentAll | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | /** |
4 | * Perform augmentation of each row and return composite result, |
5 | * indexed by ID. |
6 | */ |
7 | class PerRowAugmentor implements ResultSetAugmentor { |
8 | |
9 | /** |
10 | * @var ResultAugmentor |
11 | */ |
12 | private $rowAugmentor; |
13 | |
14 | /** |
15 | * @param ResultAugmentor $augmentor Per-result augmentor to use. |
16 | */ |
17 | public function __construct( ResultAugmentor $augmentor ) { |
18 | $this->rowAugmentor = $augmentor; |
19 | } |
20 | |
21 | /** |
22 | * Produce data to augment search result set. |
23 | * @param ISearchResultSet $resultSet |
24 | * @return array Data for all results |
25 | */ |
26 | public function augmentAll( ISearchResultSet $resultSet ) { |
27 | $data = []; |
28 | foreach ( $resultSet->extractResults() as $result ) { |
29 | $id = $result->getTitle()->getArticleID(); |
30 | if ( !$id ) { |
31 | continue; |
32 | } |
33 | $data[$id] = $this->rowAugmentor->augment( $result ); |
34 | } |
35 | return $data; |
36 | } |
37 | } |