Suggestions::startOffset()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 2
nop 0
crap 12
1
<?php
2
3
namespace PSolr\Response;
4
5
class Suggestions extends Response
6
{
7
    /**
8
     * Iterates over the suggestions
9
     *
10
     * @return \ArrayIterator
11
     */
12
    public function getIterator()
13
    {
14
        return new \ArrayIterator($this->suggestions());
15
    }
16
17
    /**
18
     * @return array
19
     */
20 View Code Duplication
    public function suggestions()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
21
    {
22
        if (isset($this->params['q']) && isset($this['spellcheck']['suggestions'][$this->params['q']]['suggestion'])) {
23
            return $this['spellcheck']['suggestions'][$this->params['q']]['suggestion'];
24
        } else {
25
            return array();
26
        }
27
    }
28
29
    /**
30
     * @return int
31
     */
32 View Code Duplication
    public function numFound()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
    {
34
        if (isset($this->params['q']) && isset($this['spellcheck']['suggestions'][$this->params['q']]['numFound'])) {
35
            return $this['spellcheck']['suggestions'][$this->params['q']]['numFound'];
36
        } else {
37
            return 0;
38
        }
39
    }
40
41
    /**
42
     * @return int
43
     */
44 View Code Duplication
    public function startOffset()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46
        if (isset($this->params['q']) && isset($this['spellcheck']['suggestions'][$this->params['q']]['startOffset'])) {
47
            return $this['spellcheck']['suggestions'][$this->params['q']]['startOffset'];
48
        } else {
49
            return 0;
50
        }
51
    }
52
53
    /**
54
     * @return int
55
     */
56 View Code Duplication
    public function endOffset()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
57
    {
58
        if (isset($this->params['q']) && isset($this['spellcheck']['suggestions'][$this->params['q']]['endOffset'])) {
59
            return $this['spellcheck']['suggestions'][$this->params['q']]['endOffset'];
60
        } else {
61
            return 0;
62
        }
63
    }
64
65
    /**
66
     * @return string
67
     */
68 View Code Duplication
    public function collation()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
    {
70
        if (isset($this['spellcheck']['suggestions']['collation'])) {
71
            return $this['spellcheck']['suggestions']['collation'];
72
        } else {
73
            return '';
74
        }
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function command()
81
    {
82
        return isset($this['command']) ? $this['command'] : '';
83
    }
84
85
    /**
86
     * Returns the "collation", or recommendation.
87
     */
88
    public function __toString()
89
    {
90
        return $this->collation();
91
    }
92
}
93