Result::getTerm()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Mdiyakov\DoctrineSolrBundle\Query\Suggest\Solarium\Result;
4
5
use Solarium\Core\Query\Result\QueryType as BaseResult;
6
7
class Result extends BaseResult implements \IteratorAggregate, \Countable
8
{
9
    /**
10
     * Status code returned by Solr
11
     *
12
     * @var int
13
     */
14
    protected $status;
15
16
    /**
17
     * Solr index queryTime
18
     *
19
     * This doesn't include things like the HTTP responsetime. Purely the Solr
20
     * query execution time.
21
     *
22
     * @var int
23
     */
24
    protected $queryTime;
25
26
    /**
27
     * Suggester results
28
     *
29
     * @var array
30
     */
31
    protected $results;
32
33
    /**
34
     * Suggester flat results
35
     *
36
     * @var array
37
     */
38
    protected $all;
39
40
    /**
41
     * Get Solr status code
42
     *
43
     * This is not the HTTP status code! The normal value for success is 0.
44
     *
45
     * @return int
46
     */
47
    public function getStatus()
48
    {
49
        $this->parseResponse();
50
51
        return $this->status;
52
    }
53
54
    /**
55
     * Get Solr query time
56
     *
57
     * This doesn't include things like the HTTP responsetime. Purely the Solr
58
     * query execution time.
59
     *
60
     * @return int
61
     */
62
    public function getQueryTime()
63
    {
64
        $this->parseResponse();
65
66
        return $this->queryTime;
67
    }
68
69
    /**
70
     * Get all results
71
     *
72
     * @return array
73
     */
74
    public function getResults()
75
    {
76
        $this->parseResponse();
77
78
        return $this->results;
79
    }
80
81
    /**
82
     * Get results for a specific term
83
     *
84
     * @param  string $term
85
     * @return array
86
     */
87
    public function getTerm($term)
88
    {
89
        $this->parseResponse();
90
91
        if (isset($this->results[$term])) {
92
            return $this->results[$term];
93
        } else {
94
            return array();
95
        }
96
    }
97
98
    /**
99
     * IteratorAggregate implementation
100
     *
101
     * @return \ArrayIterator
102
     */
103
    public function getIterator()
104
    {
105
        $this->parseResponse();
106
107
        return new \ArrayIterator($this->results);
108
    }
109
110
    /**
111
     * Countable implementation
112
     *
113
     * @return int
114
     */
115
    public function count()
116
    {
117
        $this->parseResponse();
118
119
        return count($this->results);
120
    }
121
}