Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
TitleResultsType
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 6
90
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
6
 getFields
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHighlightingConfiguration
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 transformElasticsearchResult
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 createEmptyResult
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTitleHelper
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace CirrusSearch\Search;
4
5use Elastica\ResultSet as ElasticaResultSet;
6
7/**
8 * Returns titles and makes no effort to figure out how the titles matched.
9 */
10class TitleResultsType extends BaseResultsType {
11
12    /**
13     * @var TitleHelper
14     */
15    private $titleHelper;
16
17    public function __construct( ?TitleHelper $titleHelper = null ) {
18        $this->titleHelper = $titleHelper ?: new TitleHelper();
19    }
20
21    /**
22     * @return array corresponding to Elasticsearch fields syntax
23     */
24    public function getFields() {
25        return [];
26    }
27
28    /**
29     * @param array $extraHighlightFields
30     * @return array|null
31     */
32    public function getHighlightingConfiguration( array $extraHighlightFields = [] ) {
33        return null;
34    }
35
36    /**
37     * @param ElasticaResultSet $resultSet
38     * @return mixed Set of search results, the types of which vary by implementation.
39     */
40    public function transformElasticsearchResult( ElasticaResultSet $resultSet ) {
41        $results = [];
42        foreach ( $resultSet->getResults() as $r ) {
43            $results[] = $this->getTitleHelper()->makeTitle( $r );
44        }
45        return $results;
46    }
47
48    /**
49     * @return array
50     */
51    public function createEmptyResult() {
52        return [];
53    }
54
55    /**
56     * @return TitleHelper
57     */
58    public function getTitleHelper(): TitleHelper {
59        if ( $this->titleHelper === null ) {
60            $this->titleHelper = new TitleHelper();
61        }
62        return $this->titleHelper;
63    }
64}