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
Push — master ( 42533c...5611c9 )
by Dragos
13:44
created

Device::txPower()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Speicher210\KontaktIO\Model;
6
7
use JMS\Serializer\Annotation as JMS;
8
9
/**
10
 * Model representing a device.
11
 */
12
final class Device
13
{
14
    public const PROXIMITY_IMMEDIATE = 'IMMEDIATE';
15
    public const PROXIMITY_NEAR = 'NEAR';
16
    public const PROXIMITY_FAR = 'FAR';
17
18
    public const DEVICE_TYPE_BEACON = 'BEACON';
19
    public const DEVICE_TYPE_CLOUD_BEACON = 'CLOUD_BEACON';
20
21
    public const PROFILE_IBEACON = 'IBEACON';
22
    public const PROFILE_EDDYSTONE = 'EDDYSTONE';
23
24
    public const SPECIFICATION_STANDARD = 'STANDARD';
25
    public const SPECIFICATION_SENSOR = 'SENSOR';
26
    public const SPECIFICATION_TOUGH = 'TOUGH';
27
28
    public const MODEL_CARD_BEACON = 'CARD_BEACON';
29
    public const MODEL_CLOUD_BEACON = 'CLOUD_BEACON';
30
    public const MODEL_EXTERNAL = 'EXTERNAL';
31
    public const MODEL_GATEWAY = 'GATEWAY';
32
    public const MODEL_SENSOR_BEACON = 'SENSOR_BEACON';
33
    public const MODEL_SMART_BEACON = 'SMART_BEACON';
34
    public const MODEL_USB_BEACON = 'USB_BEACON';
35
36
    /**
37
     * @param string $id Device ID.
38
     * @param string $uniqueId Device unique ID.
39
     */
40
    public function __construct(string $id, string $uniqueId)
41
    {
42
        $this->id = $id;
43
        $this->uniqueId = $uniqueId;
44
    }
45
46
    /**
47
     * Device ID.
48
     *
49
     * This is an UUID.
50
     *
51
     * @var string
52
     *
53
     * @JMS\Type("string")
54
     * @JMS\SerializedName("id")
55
     */
56
    private $id;
57
58
    /**
59
     * Device unique ID.
60
     *
61
     * @var string
62
     *
63
     * @JMS\Type("string")
64
     * @JMS\SerializedName("uniqueId")
65
     */
66
    private $uniqueId;
67
68
    /**
69
     * Eddystone namespace.
70
     *
71
     * @var string
72
     *
73
     * @JMS\Type("string")
74
     * @JMS\SerializedName("namespace")
75
     */
76
    private $namespace;
77
78
    /**
79
     * Eddystone ID.
80
     *
81
     * @var string
82
     *
83
     * @JMS\Type("string")
84
     * @JMS\SerializedName("instanceId")
85
     */
86
    private $instanceId;
87
88
    /**
89
     * Device type.
90
     *
91
     * @var string
92
     *
93
     * @JMS\Type("string")
94
     * @JMS\SerializedName("deviceType")
95
     */
96
    private $deviceType;
97
98
    /**
99
     * Specification.
100
     *
101
     * @var string
102
     *
103
     * @JMS\Type("string")
104
     * @JMS\SerializedName("specification")
105
     */
106
    private $specification;
107
108
    /**
109
     * Proximity UUID.
110
     *
111
     * The UUID of the device.
112
     *
113
     * @var string
114
     *
115
     * @JMS\Type("string")
116
     * @JMS\SerializedName("proximity")
117
     */
118
    private $proximity;
119
120
    /**
121
     * Major.
122
     *
123
     * @var integer
124
     *
125
     * @JMS\Type("integer")
126
     * @JMS\SerializedName("major")
127
     */
128
    private $major;
129
130
    /**
131
     * Minor.
132
     *
133
     * @var integer
134
     *
135
     * @JMS\Type("integer")
136
     * @JMS\SerializedName("minor")
137
     */
138
    private $minor;
139
140
    /**
141
     * Device name.
142
     *
143
     * @var string
144
     *
145
     * @JMS\Type("string")
146
     * @JMS\SerializedName("name")
147
     */
148
    private $name;
149
150
    /**
151
     * Device alias.
152
     *
153
     * @var string
154
     *
155
     * @JMS\Type("string")
156
     * @JMS\SerializedName("alias")
157
     */
158
    private $alias;
159
160
    /**
161
     * The model.
162
     *
163
     * @var string
164
     *
165
     * @JMS\Type("string")
166
     * @JMS\SerializedName("model")
167
     */
168
    private $model;
169
170
    /**
171
     * Advertising interval range (20 - 10240 milliseconds).
172
     *
173
     * @var integer
174
     *
175
     * @JMS\Type("integer")
176
     * @JMS\SerializedName("interval")
177
     */
178
    private $interval;
179
180
    /**
181
     * Transmission power (0 - 7).
182
     *
183
     * @var integer
184
     *
185
     * @JMS\Type("integer")
186
     * @JMS\SerializedName("txPower")
187
     */
188
    private $txPower;
189
190
    /**
191
     * Device URL.
192
     *
193
     * @var string
194
     *
195
     * @JMS\Type("string")
196
     * @JMS\SerializedName("url")
197
     */
198
    private $url;
199
200
    /**
201
     * Firmware version of the device
202
     *
203
     * @var string
204
     *
205
     * @JMS\Type("string")
206
     * @JMS\SerializedName("firmware")
207
     */
208
    private $firmware;
209
210
    /**
211
     * Device profile.
212
     *
213
     * @var array
214
     *
215
     * @JMS\Type("array")
216
     * @JMS\SerializedName("profiles")
217
     */
218
    private $profiles;
219
220
    /**
221
     * Get the ID.
222
     *
223
     * @return string
224
     */
225
    public function id()
226
    {
227
        return $this->id;
228
    }
229
230
    /**
231
     * Get the unique ID.
232
     *
233
     * @return string
234
     */
235
    public function uniqueId()
236
    {
237
        return $this->uniqueId;
238
    }
239
240
    /**
241
     * Get the namespace.
242
     *
243
     * @return string
244
     */
245
    public function namespace()
0 ignored issues
show
Coding Style introduced by
Possible parse error: non-abstract method defined as abstract
Loading history...
246
    {
247
        return $this->namespace;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $this.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
248
    }
249
250
    /**
251
     * Set the namespace.
252
     *
253
     * @param string $namespace The namespace.
254
     * @return Device
255
     */
256
    public function setNamespace($namespace)
257
    {
258
        $this->namespace = $namespace;
259
260
        return $this;
261
    }
262
263
    /**
264
     * Get the instance ID.
265
     *
266
     * @return string
267
     */
268
    public function instanceId()
269
    {
270
        return $this->instanceId;
271
    }
272
273
    /**
274
     * Set the instance ID.
275
     *
276
     * @param string $instanceId The instance ID.
277
     * @return Device
278
     */
279
    public function setInstanceId($instanceId)
280
    {
281
        $this->instanceId = $instanceId;
282
283
        return $this;
284
    }
285
286
    /**
287
     * Get the device type.
288
     *
289
     * @return string
290
     */
291
    public function deviceType()
292
    {
293
        return $this->deviceType;
294
    }
295
296
    /**
297
     * Set the device type.
298
     *
299
     * @param string $deviceType The device type.
300
     * @return Device
301
     */
302
    public function setDeviceType($deviceType)
303
    {
304
        $this->deviceType = $deviceType;
305
306
        return $this;
307
    }
308
309
    /**
310
     * Get the specifications.
311
     *
312
     * @return string
313
     */
314
    public function specification()
315
    {
316
        return $this->specification;
317
    }
318
319
    /**
320
     * Set the specifications.
321
     *
322
     * @param string $specification The specifications.
323
     * @return Device
324
     */
325
    public function setSpecification($specification)
326
    {
327
        $this->specification = $specification;
328
329
        return $this;
330
    }
331
332
    /**
333
     * Get the proximity.
334
     *
335
     * @return string
336
     */
337
    public function proximity(): string
338
    {
339
        return $this->proximity;
340
    }
341
342
    /**
343
     * Set the proximity UUID.
344
     *
345
     * @param string $proximity The proximity UUID.
346
     * @return Device
347
     */
348
    public function setProximity(string $proximity)
349
    {
350
        $this->proximity = $proximity;
351
352
        return $this;
353
    }
354
355
    /**
356
     * Get the major.
357
     *
358
     * @return integer
359
     */
360
    public function major(): int
361
    {
362
        return $this->major;
363
    }
364
365
    /**
366
     * Set the major.
367
     *
368
     * @param integer $major The major.
369
     * @return Device
370
     */
371
    public function setMajor(int $major)
372
    {
373
        $this->major = $major;
374
375
        return $this;
376
    }
377
378
    /**
379
     * Get the minor.
380
     *
381
     * @return integer
382
     */
383
    public function minor(): int
384
    {
385
        return $this->minor;
386
    }
387
388
    /**
389
     * Set the minor.
390
     *
391
     * @param integer $minor The minor.
392
     * @return Device
393
     */
394
    public function setMinor(int $minor)
395
    {
396
        $this->minor = $minor;
397
398
        return $this;
399
    }
400
401
    /**
402
     * Get the name.
403
     *
404
     * @return string
405
     */
406
    public function name(): string
407
    {
408
        return $this->name;
409
    }
410
411
    /**
412
     * Set the name.
413
     *
414
     * @param string $name The name.
415
     * @return Device
416
     */
417
    public function setName($name)
418
    {
419
        $this->name = $name;
420
421
        return $this;
422
    }
423
424
    /**
425
     * Get the alias.
426
     *
427
     * @return string
428
     */
429
    public function alias(): ?string
430
    {
431
        return $this->alias;
432
    }
433
434
    /**
435
     * Set the alias.
436
     *
437
     * @param string $alias The alias.
438
     * @return Device
439
     */
440
    public function setAlias(?string $alias)
441
    {
442
        $this->alias = $alias;
443
444
        return $this;
445
    }
446
447
    /**
448
     * Get the model.
449
     *
450
     * @return string
451
     */
452
    public function model(): string
453
    {
454
        return $this->model;
455
    }
456
457
    /**
458
     * Set the model.
459
     *
460
     * @param string $model
461
     * @return Device
462
     */
463
    public function setModel(string $model): Device
464
    {
465
        $this->model = $model;
466
        return $this;
467
    }
468
469
    /**
470
     * Get the broadcast interval in milliseconds.
471
     *
472
     * @return integer
473
     */
474
    public function interval(): int
475
    {
476
        return $this->interval;
477
    }
478
479
    /**
480
     * Set the broadcast interval.
481
     *
482
     * @param integer $interval The interval in milliseconds.
483
     * @return Device
484
     */
485
    public function setInterval(int $interval)
486
    {
487
        $this->interval = $interval;
488
489
        return $this;
490
    }
491
492
    /**
493
     * Get the TX power.
494
     *
495
     * @return integer
496
     */
497
    public function txPower(): int
498
    {
499
        return $this->txPower;
500
    }
501
502
    /**
503
     * Set the TX power.
504
     *
505
     * @param integer $txPower
506
     * @return Device
507
     */
508
    public function setTxPower($txPower)
509
    {
510
        $this->txPower = $txPower;
511
512
        return $this;
513
    }
514
515
    /**
516
     * Get the URL.
517
     *
518
     * @return string
519
     */
520
    public function url(): ?string
521
    {
522
        return $this->url;
523
    }
524
525
    /**
526
     * Set the URL.
527
     *
528
     * @param string $url The URL.
529
     * @return Device
530
     */
531
    public function setUrl(?string $url)
532
    {
533
        $this->url = $url;
534
535
        return $this;
536
    }
537
538
    /**
539
     * Get the firmware version.
540
     *
541
     * @return string
542
     */
543
    public function firmware(): ?string
544
    {
545
        return $this->firmware;
546
    }
547
548
    /**
549
     * Set the firmware.
550
     *
551
     * @param string $firmware
552
     * @return Device
553
     */
554
    public function setFirmware(string $firmware)
555
    {
556
        $this->firmware = $firmware;
557
        return $this;
558
    }
559
560
    /**
561
     * Get the profiles.
562
     *
563
     * @return array
564
     */
565
    public function profiles(): ?array
566
    {
567
        return $this->profiles;
568
    }
569
570
    /**
571
     * Set the profiles.
572
     *
573
     * @param array|null $profiles
574
     * @return Device
575
     */
576
    public function setProfiles(?array $profiles)
577
    {
578
        $this->profiles = $profiles;
0 ignored issues
show
Documentation Bug introduced by
It seems like $profiles can be null. However, the property $profiles is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
579
580
        return $this;
581
    }
582
}
583