Suggestions   A
last analyzed

Complexity

Total Complexity 18

Size/Duplication

Total Lines 88
Duplicated Lines 45.45 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 18
lcom 1
cbo 1
dl 40
loc 88
ccs 0
cts 52
cp 0
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getIterator() 0 4 1
A suggestions() 8 8 3
A numFound() 8 8 3
A startOffset() 8 8 3
A endOffset() 8 8 3
A collation() 8 8 2
A command() 0 4 2
A __toString() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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