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 | private ResultAugmentor $rowAugmentor; |
10 | |
11 | /** |
12 | * @param ResultAugmentor $augmentor Per-result augmentor to use. |
13 | */ |
14 | public function __construct( ResultAugmentor $augmentor ) { |
15 | $this->rowAugmentor = $augmentor; |
16 | } |
17 | |
18 | /** |
19 | * Produce data to augment search result set. |
20 | * @param ISearchResultSet $resultSet |
21 | * @return array Data for all results |
22 | */ |
23 | public function augmentAll( ISearchResultSet $resultSet ) { |
24 | $data = []; |
25 | foreach ( $resultSet->extractResults() as $result ) { |
26 | $id = $result->getTitle()->getArticleID(); |
27 | if ( !$id ) { |
28 | continue; |
29 | } |
30 | $data[$id] = $this->rowAugmentor->augment( $result ); |
31 | } |
32 | return $data; |
33 | } |
34 | } |