CorosFitSdkMapping   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 40
rs 10
c 0
b 0
f 0
ccs 9
cts 9
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMapping() 0 16 1
A __construct() 0 4 1
A toInternal() 0 8 2
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