PlaceAutocompletePrediction   A
last analyzed

Complexity

Total Complexity 36

Size/Duplication

Total Lines 251
Duplicated Lines 0 %

Coupling/Cohesion

Components 5
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 36
lcom 5
cbo 0
dl 0
loc 251
ccs 80
cts 80
cp 1
rs 9.52
c 0
b 0
f 0

27 Methods

Rating   Name   Duplication   Size   Complexity  
A hasPlaceId() 0 4 1
A getPlaceId() 0 4 1
A setPlaceId() 0 4 1
A hasDescription() 0 4 1
A getDescription() 0 4 1
A setDescription() 0 4 1
A hasTypes() 0 4 1
A getTypes() 0 4 1
A setTypes() 0 5 1
A addTypes() 0 6 2
A hasType() 0 4 1
A addType() 0 6 2
A removeType() 0 5 2
A hasTerms() 0 4 1
A getTerms() 0 4 1
A setTerms() 0 5 1
A addTerms() 0 6 2
A hasTerm() 0 4 1
A addTerm() 0 6 2
A removeTerm() 0 5 2
A hasMatches() 0 4 1
A getMatches() 0 4 1
A setMatches() 0 5 1
A addMatches() 0 6 2
A hasMatch() 0 4 1
A addMatch() 0 6 2
A removeMatch() 0 5 2
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
/**
15
 * @author GeLo <[email protected]>
16
 */
17
class PlaceAutocompletePrediction
18
{
19
    /**
20
     * @var string|null
21
     */
22
    private $placeId;
23
24
    /**
25
     * @var string|null
26
     */
27
    private $description;
28
29
    /**
30
     * @var string[]
31
     */
32
    private $types = [];
33
34
    /**
35
     * @var PlaceAutocompleteTerm[]
36
     */
37
    private $terms = [];
38
39
    /**
40
     * @var PlaceAutocompleteMatch[]
41
     */
42
    private $matches = [];
43
44
    /**
45
     * @return bool
46
     */
47 8
    public function hasPlaceId()
48
    {
49 8
        return null !== $this->placeId;
50
    }
51
52
    /**
53
     * @return string|null
54
     */
55 8
    public function getPlaceId()
56
    {
57 8
        return $this->placeId;
58
    }
59
60
    /**
61
     * @param string|null $placeId
62
     */
63 4
    public function setPlaceId($placeId)
64
    {
65 4
        $this->placeId = $placeId;
66 4
    }
67
68
    /**
69
     * @return bool
70
     */
71 8
    public function hasDescription()
72
    {
73 8
        return null !== $this->description;
74
    }
75
76
    /**
77
     * @return string|null
78
     */
79 8
    public function getDescription()
80
    {
81 8
        return $this->description;
82
    }
83
84
    /**
85
     * @param string|null $description
86
     */
87 4
    public function setDescription($description)
88
    {
89 4
        $this->description = $description;
90 4
    }
91
92
    /**
93
     * @return bool
94
     */
95 20
    public function hasTypes()
96
    {
97 20
        return !empty($this->types);
98
    }
99
100
    /**
101
     * @return string[]
102
     */
103 20
    public function getTypes()
104
    {
105 20
        return $this->types;
106
    }
107
108
    /**
109
     * @param string[] $types
110
     */
111 8
    public function setTypes(array $types)
112
    {
113 8
        $this->types = [];
114 8
        $this->addTypes($types);
115 8
    }
116
117
    /**
118
     * @param string[] $types
119
     */
120 8
    public function addTypes(array $types)
121
    {
122 8
        foreach ($types as $type) {
123 8
            $this->addType($type);
124
        }
125 8
    }
126
127
    /**
128
     * @param string $type
129
     *
130
     * @return bool
131
     */
132 16
    public function hasType($type)
133
    {
134 16
        return in_array($type, $this->types, true);
135
    }
136
137
    /**
138
     * @param string $type
139
     */
140 16
    public function addType($type)
141
    {
142 16
        if (!$this->hasType($type)) {
143 16
            $this->types[] = $type;
144
        }
145 16
    }
146
147
    /**
148
     * @param string $type
149
     */
150 4
    public function removeType($type)
151
    {
152 4
        unset($this->types[array_search($type, $this->types, true)]);
153 4
        $this->types = empty($this->types) ? [] : array_values($this->types);
154 4
    }
155
156
    /**
157
     * @return bool
158
     */
159 20
    public function hasTerms()
160
    {
161 20
        return !empty($this->terms);
162
    }
163
164
    /**
165
     * @return PlaceAutocompleteTerm[]
166
     */
167 20
    public function getTerms()
168
    {
169 20
        return $this->terms;
170
    }
171
172
    /**
173
     * @param PlaceAutocompleteTerm[] $terms
174
     */
175 8
    public function setTerms(array $terms)
176
    {
177 8
        $this->terms = [];
178 8
        $this->addTerms($terms);
179 8
    }
180
181
    /**
182
     * @param PlaceAutocompleteTerm[] $terms
183
     */
184 8
    public function addTerms(array $terms)
185
    {
186 8
        foreach ($terms as $term) {
187 8
            $this->addTerm($term);
188
        }
189 8
    }
190
191
    /**
192
     * @return bool
193
     */
194 16
    public function hasTerm(PlaceAutocompleteTerm $term)
195
    {
196 16
        return in_array($term, $this->terms, true);
197
    }
198
199 16
    public function addTerm(PlaceAutocompleteTerm $term)
200
    {
201 16
        if (!$this->hasTerm($term)) {
202 16
            $this->terms[] = $term;
203
        }
204 16
    }
205
206 4
    public function removeTerm(PlaceAutocompleteTerm $term)
207
    {
208 4
        unset($this->terms[array_search($term, $this->terms, true)]);
209 4
        $this->terms = empty($this->terms) ? [] : array_values($this->terms);
210 4
    }
211
212
    /**
213
     * @return bool
214
     */
215 20
    public function hasMatches()
216
    {
217 20
        return !empty($this->matches);
218
    }
219
220
    /**
221
     * @return PlaceAutocompleteMatch[]
222
     */
223 20
    public function getMatches()
224
    {
225 20
        return $this->matches;
226
    }
227
228
    /**
229
     * @param PlaceAutocompleteMatch[] $matches
230
     */
231 8
    public function setMatches(array $matches)
232
    {
233 8
        $this->matches = [];
234 8
        $this->addMatches($matches);
235 8
    }
236
237
    /**
238
     * @param PlaceAutocompleteMatch[] $matches
239
     */
240 8
    public function addMatches(array $matches)
241
    {
242 8
        foreach ($matches as $match) {
243 8
            $this->addMatch($match);
244
        }
245 8
    }
246
247
    /**
248
     * @return bool
249
     */
250 16
    public function hasMatch(PlaceAutocompleteMatch $match)
251
    {
252 16
        return in_array($match, $this->matches, true);
253
    }
254
255 16
    public function addMatch(PlaceAutocompleteMatch $match)
256
    {
257 16
        if (!$this->hasMatch($match)) {
258 16
            $this->matches[] = $match;
259
        }
260 16
    }
261
262 4
    public function removeMatch(PlaceAutocompleteMatch $match)
263
    {
264 4
        unset($this->matches[array_search($match, $this->matches, true)]);
265 4
        $this->matches = empty($this->matches) ? [] : array_values($this->matches);
266 4
    }
267
}
268