CorosFitSdkMapping::getMapping()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 2
cts 2
cp 1
rs 9.7333
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Runalyze Device List.
5
 *
6
 * (c) RUNALYZE <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Runalyze\Devices\Mapping;
13
14
use Runalyze\Devices\Device\DeviceProfile;
15
16
class CorosFitSdkMapping
17
{
18
    /** @var int[]|string[] */
19
    protected $Mapping = [];
20
21 1
    protected function getMapping()
22
    {
23
        return [
24 1
            801 => DeviceProfile::COROS_PACE,
25
            802 => DeviceProfile::COROS_PACE_2,
26
            811 => DeviceProfile::COROS_APEX_42,
27
            821 => DeviceProfile::COROS_APEX_46,
28
            831 => DeviceProfile::COROS_VERTIX,
29
            841 => DeviceProfile::COROS_APEX_PRO,
30
            899 => DeviceProfile::COROS_UNKNOWN,
31
        ];
32
        /*
33
         * Unknown:
34
         * 899
35
         */
36
    }
37
38 1
    public function __construct()
39
    {
40 1
        $this->Mapping = $this->getMapping();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMapping() of type array<integer,?> is incompatible with the declared type array<integer,integer|string> of property $Mapping.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

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

Loading history...
41 1
    }
42
43
    /**
44
     * @param  int|string $value
45
     * @return int|string
46
     */
47 1
    public function toInternal($value)
48
    {
49 1
        if (isset($this->Mapping[$value])) {
50 1
            return $this->Mapping[$value];
51
        }
52
53 1
        return;
54
    }
55
}
56