GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#177)
by Eric
08:46 queued 06:24
created

PlaceAutocompleteResponse   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 129
Duplicated Lines 100 %

Coupling/Cohesion

Components 3
Dependencies 0

Importance

Changes 0
Metric Value
wmc 15
lcom 3
cbo 0
dl 129
loc 129
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A hasStatus() 4 4 1
A getStatus() 4 4 1
A setStatus() 4 4 1
A hasRequest() 4 4 1
A getRequest() 4 4 1
A setRequest() 4 4 1
A hasPredictions() 4 4 1
A getPredictions() 4 4 1
A setPredictions() 5 5 1
A addPredictions() 6 6 2
A hasPrediction() 4 4 1
A addPrediction() 6 6 2
A removePrediction() 5 5 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
/*
4
 * This file is part of the Ivory Google Map package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMap\Service\Place\Autocomplete\Response;
13
14
use Ivory\GoogleMap\Service\Place\Autocomplete\Request\PlaceAutocompleteRequestInterface;
15
16
/**
17
 * @author GeLo <[email protected]>
18
 */
19 View Code Duplication
class PlaceAutocompleteResponse
0 ignored issues
show
Duplication introduced by
This class 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...
20
{
21
    /**
22
     * @var string|null
23
     */
24
    private $status;
25
26
    /**
27
     * @var PlaceAutocompleteRequestInterface|null
28
     */
29
    private $request;
30
31
    /**
32
     * @var PlaceAutocompletePrediction[]
33
     */
34
    private $predictions = [];
35
36
    /**
37
     * @return bool
38
     */
39
    public function hasStatus()
40
    {
41
        return $this->status !== null;
42
    }
43
44
    /**
45
     * @return string|null
46
     */
47
    public function getStatus()
48
    {
49
        return $this->status;
50
    }
51
52
    /**
53
     * @param string|null $status
54
     */
55
    public function setStatus($status)
56
    {
57
        $this->status = $status;
58
    }
59
60
    /**
61
     * @return bool
62
     */
63
    public function hasRequest()
64
    {
65
        return $this->request !== null;
66
    }
67
68
    /**
69
     * @return PlaceAutocompleteRequestInterface|null
70
     */
71
    public function getRequest()
72
    {
73
        return $this->request;
74
    }
75
76
    /**
77
     * @param PlaceAutocompleteRequestInterface|null $request
78
     */
79
    public function setRequest(PlaceAutocompleteRequestInterface $request = null)
80
    {
81
        $this->request = $request;
82
    }
83
84
    /**
85
     * @return bool
86
     */
87
    public function hasPredictions()
88
    {
89
        return !empty($this->predictions);
90
    }
91
92
    /**
93
     * @return PlaceAutocompletePrediction[]
94
     */
95
    public function getPredictions()
96
    {
97
        return $this->predictions;
98
    }
99
100
    /**
101
     * @param PlaceAutocompletePrediction[] $predictions
102
     */
103
    public function setPredictions(array $predictions)
104
    {
105
        $this->predictions = [];
106
        $this->addPredictions($predictions);
107
    }
108
109
    /**
110
     * @param PlaceAutocompletePrediction[] $predictions
111
     */
112
    public function addPredictions(array $predictions)
113
    {
114
        foreach ($predictions as $prediction) {
115
            $this->addPrediction($prediction);
116
        }
117
    }
118
119
    /**
120
     * @param PlaceAutocompletePrediction $prediction
121
     *
122
     * @return bool
123
     */
124
    public function hasPrediction(PlaceAutocompletePrediction $prediction)
125
    {
126
        return in_array($prediction, $this->predictions, true);
127
    }
128
129
    /**
130
     * @param PlaceAutocompletePrediction $prediction
131
     */
132
    public function addPrediction(PlaceAutocompletePrediction $prediction)
133
    {
134
        if (!$this->hasPrediction($prediction)) {
135
            $this->predictions[] = $prediction;
136
        }
137
    }
138
139
    /**
140
     * @param PlaceAutocompletePrediction $prediction
141
     */
142
    public function removePrediction(PlaceAutocompletePrediction $prediction)
143
    {
144
        unset($this->predictions[array_search($prediction, $this->predictions, true)]);
145
        $this->predictions = array_values($this->predictions);
146
    }
147
}
148