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.

Autocomplete::setValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
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\Place;
13
14
use Ivory\GoogleMap\Base\Bound;
15
use Ivory\GoogleMap\Event\EventManager;
16
use Ivory\GoogleMap\Utility\VariableAwareInterface;
17
use Ivory\GoogleMap\Utility\VariableAwareTrait;
18
19
/**
20
 * @author GeLo <[email protected]>
21
 */
22
class Autocomplete implements VariableAwareInterface
23
{
24
    use VariableAwareTrait;
25
26
    /**
27
     * @var string
28
     */
29
    private $inputId = 'place_input';
30
31
    /**
32
     * @var EventManager
33
     */
34
    private $eventManager;
35
36
    /**
37
     * @var Bound|null
38
     */
39
    private $bound;
40
41
    /**
42
     * @var string[]
43
     */
44
    private $types = [];
45
46
    /**
47
     * @var mixed[]
48
     */
49
    private $components = [];
50
51
    /**
52
     * @var string
53
     */
54
    private $value;
55
56
    /**
57
     * @var string[]
58
     */
59
    private $inputAttributes = [];
60
61
    /**
62
     * @var string[]
63
     */
64
    private $libraries = [];
65
66 184
    public function __construct()
67
    {
68 184
        $this->setEventManager(new EventManager());
69 184
    }
70
71
    /**
72
     * @return string
73
     */
74 72
    public function getHtmlId()
75
    {
76 72
        return $this->inputId;
77
    }
78
79
    /**
80
     * @param string $inputId
81
     */
82 4
    public function setInputId($inputId)
83
    {
84 4
        $this->inputId = $inputId;
85 4
    }
86
87
    /**
88
     * @return EventManager
89
     */
90 72
    public function getEventManager()
91
    {
92 72
        return $this->eventManager;
93
    }
94
95
    /**
96
     * @param EventManager $eventManager
97
     */
98 184
    public function setEventManager(EventManager $eventManager)
99
    {
100 184
        $this->eventManager = $eventManager;
101 184
    }
102
103
    /**
104
     * @return bool
105
     */
106 84
    public function hasBound()
107
    {
108 84
        return $this->bound !== null;
109
    }
110
111
    /**
112
     * @return Bound|null
113
     */
114 28
    public function getBound()
115
    {
116 28
        return $this->bound;
117
    }
118
119
    /**
120
     * @param Bound|null $bound
121
     */
122 24
    public function setBound(Bound $bound = null)
123
    {
124 24
        $this->bound = $bound;
125 24
    }
126
127
    /**
128
     * @return bool
129
     */
130 76
    public function hasTypes()
131
    {
132 76
        return !empty($this->types);
133
    }
134
135
    /**
136
     * @return string[]
137
     */
138 28
    public function getTypes()
139
    {
140 28
        return $this->types;
141
    }
142
143
    /**
144
     * @param string[] $types
145
     */
146 16
    public function setTypes(array $types)
147
    {
148 16
        $this->types = [];
149 16
        $this->addTypes($types);
150 16
    }
151
152
    /**
153
     * @param string[] $types
154
     */
155 16
    public function addTypes(array $types)
156
    {
157 16
        foreach ($types as $type) {
158 16
            $this->addType($type);
159 8
        }
160 16
    }
161
162
    /**
163
     * @param string $type
164
     *
165
     * @return bool
166
     */
167 24
    public function hasType($type)
168
    {
169 24
        return in_array($type, $this->types, true);
170
    }
171
172
    /**
173
     * @param string $type
174
     */
175 24
    public function addType($type)
176
    {
177 24
        if (!$this->hasType($type)) {
178 24
            $this->types[] = $type;
179 12
        }
180 24
    }
181
182
    /**
183
     * @param string $type
184
     */
185 4
    public function removeType($type)
186
    {
187 4
        unset($this->types[array_search($type, $this->types, true)]);
188 4
        $this->types = empty($this->types) ? [] : array_values($this->types);
189 4
    }
190
191
    /**
192
     * @return bool
193
     */
194 76
    public function hasComponents()
195
    {
196 76
        return !empty($this->components);
197
    }
198
199
    /**
200
     * @return mixed[]
201
     */
202 28
    public function getComponents()
203
    {
204 28
        return $this->components;
205
    }
206
207
    /**
208
     * @param mixed[] $components
209
     */
210 16
    public function setComponents(array $components)
211
    {
212 16
        $this->components = [];
213 16
        $this->addComponents($components);
214 16
    }
215
216
    /**
217
     * @param mixed[] $components
218
     */
219 16
    public function addComponents(array $components)
220
    {
221 16
        foreach ($components as $type => $value) {
222 16
            $this->setComponent($type, $value);
223 8
        }
224 16
    }
225
226
    /**
227
     * @param string $type
228
     *
229
     * @return bool
230
     */
231 12
    public function hasComponent($type)
232
    {
233 12
        return isset($this->components[$type]);
234
    }
235
236
    /**
237
     * @param string $type
238
     *
239
     * @return mixed
240
     */
241 12
    public function getComponent($type)
242
    {
243 12
        return $this->hasComponent($type) ? $this->components[$type] : null;
244
    }
245
246
    /**
247
     * @param string $type
248
     * @param mixed  $value
249
     */
250 24
    public function setComponent($type, $value)
251
    {
252 24
        $this->components[$type] = $value;
253 24
    }
254
255
    /**
256
     * @param string $type
257
     */
258 4
    public function removeComponent($type)
259
    {
260 4
        unset($this->components[$type]);
261 4
    }
262
263
    /**
264
     * @return bool
265
     */
266 60
    public function hasValue()
267
    {
268 60
        return $this->value !== null;
269
    }
270
271
    /**
272
     * @return string|null
273
     */
274 52
    public function getValue()
275
    {
276 52
        return $this->value;
277
    }
278
279
    /**
280
     * @param string|null $value
281
     */
282 8
    public function setValue($value = null)
283
    {
284 8
        $this->value = $value;
285 8
    }
286
287
    /**
288
     * @return bool
289
     */
290 20
    public function hasInputAttributes()
291
    {
292 20
        return !empty($this->inputAttributes);
293
    }
294
295
    /**
296
     * @return string[]
297
     */
298 76
    public function getInputAttributes()
299
    {
300 76
        return $this->inputAttributes;
301
    }
302
303
    /**
304
     * @param string[] $inputAttributes
305
     */
306 8
    public function setInputAttributes(array $inputAttributes)
307
    {
308 8
        $this->inputAttributes = [];
309 8
        $this->addInputAttributes($inputAttributes);
310 8
    }
311
312
    /**
313
     * @param string[] $inputAttributes
314
     */
315 8
    public function addInputAttributes(array $inputAttributes)
316
    {
317 8
        foreach ($inputAttributes as $name => $value) {
318 8
            $this->setInputAttribute($name, $value);
319 4
        }
320 8
    }
321
322
    /**
323
     * @param string $name
324
     *
325
     * @return bool
326
     */
327 12
    public function hasInputAttribute($name)
328
    {
329 12
        return isset($this->inputAttributes[$name]);
330
    }
331
332
    /**
333
     * @param string $name
334
     *
335
     * @return string|null
336
     */
337 12
    public function getInputAttribute($name)
338
    {
339 12
        return $this->hasInputAttribute($name) ? $this->inputAttributes[$name] : null;
340
    }
341
342
    /**
343
     * @param string $name
344
     * @param string $value
345
     */
346 20
    public function setInputAttribute($name, $value)
347
    {
348 20
        $this->inputAttributes[$name] = $value;
349 20
    }
350
351
    /**
352
     * @param string $name
353
     */
354 4
    public function removeInputAttribute($name)
355
    {
356 4
        unset($this->inputAttributes[$name]);
357 4
    }
358
359
    /**
360
     * @return bool
361
     */
362 64
    public function hasLibraries()
363
    {
364 64
        return !empty($this->libraries);
365
    }
366
367
    /**
368
     * @return string[]
369
     */
370 68
    public function getLibraries()
371
    {
372 68
        return $this->libraries;
373
    }
374
375
    /**
376
     * @param string[] $libraries
377
     */
378 8
    public function setLibraries(array $libraries)
379
    {
380 8
        $this->libraries = [];
381 8
        $this->addLibraries($libraries);
382 8
    }
383
384
    /**
385
     * @param string[] $libraries
386
     */
387 8
    public function addLibraries(array $libraries)
388
    {
389 8
        foreach ($libraries as $library) {
390 8
            $this->addLibrary($library);
391 4
        }
392 8
    }
393
394
    /**
395
     * @param string $library
396
     *
397
     * @return bool
398
     */
399 20
    public function hasLibrary($library)
400
    {
401 20
        return in_array($library, $this->libraries, true);
402
    }
403
404
    /**
405
     * @param string $library
406
     */
407 20
    public function addLibrary($library)
408
    {
409 20
        if (!$this->hasLibrary($library)) {
410 20
            $this->libraries[] = $library;
411 10
        }
412 20
    }
413
414
    /**
415
     * @param string $library
416
     */
417 4
    public function removeLibrary($library)
418
    {
419 4
        unset($this->libraries[array_search($library, $this->libraries, true)]);
420 4
        $this->libraries = empty($this->libraries) ? [] : array_values($this->libraries);
421 4
    }
422
}
423