DevelopmentFitSdkMapping::getMapping()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 74

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 74
ccs 0
cts 68
cp 0
rs 8.5672
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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 DevelopmentFitSdkMapping
17
{
18
    /** @var int[]|string[] */
19
    protected $Mapping = [];
20
21
    protected function getMapping()
22
    {
23
        return [
24
            'Watch1,1' => DeviceProfile::APPLE_WATCH_V_38,
25
            'Watch1,2' => DeviceProfile::APPLE_WATCH_V_42,
26
            'Watch2,6' => DeviceProfile::APPLE_WATCH_1_V_38,
27
            'Watch2,7' => DeviceProfile::APPLE_WATCH_1_V_42,
28
            'Watch2,3' => DeviceProfile::APPLE_WATCH_2_V_38,
29
            'Watch2,4' => DeviceProfile::APPLE_WATCH_2_V_42,
30
            'Watch3,1' => DeviceProfile::APPLE_WATCH_3_V_38_CELLULAR,
31
            'Watch3,2' => DeviceProfile::APPLE_WATCH_3_V_42_CELLULAR,
32
            'Watch3,3' => DeviceProfile::APPLE_WATCH_3_V_38,
33
            'Watch3,4' => DeviceProfile::APPLE_WATCH_3_V_42,
34
            'Watch4,1' => DeviceProfile::APPLE_WATCH_4_V_40,
35
            'Watch4,2' => DeviceProfile::APPLE_WATCH_4_V_44,
36
            'Watch4,3' => DeviceProfile::APPLE_WATCH_4_V_40_CELLULAR,
37
            'Watch4,4' => DeviceProfile::APPLE_WATCH_4_V_44_CELLULAR,
38
            'Watch5,1' => DeviceProfile::APPLE_WATCH_5_V_40,
39
            'Watch5,2' => DeviceProfile::APPLE_WATCH_5_V_44,
40
            'Watch5,3' => DeviceProfile::APPLE_WATCH_5_V_40_CELLULAR,
41
            'Watch5,4' => DeviceProfile::APPLE_WATCH_5_V_44_CELLULAR,
42
            'Watch5,9' => DeviceProfile::APPLE_WATCH_S_E_40,
43
            'Watch5,10' => DeviceProfile::APPLE_WATCH_S_E_44,
44
            'Watch5,11' => DeviceProfile::APPLE_WATCH_S_E_40_CELLULAR,
45
            'Watch5,12' => DeviceProfile::APPLE_WATCH_S_E_44_CELLULAR,
46
            'Watch6,1' => DeviceProfile::APPLE_WATCH_6_V_40,
47
            'Watch6,2' => DeviceProfile::APPLE_WATCH_6_V_44,
48
            'Watch6,3' => DeviceProfile::APPLE_WATCH_6_V_40_CELLULAR,
49
            'Watch6,4' => DeviceProfile::APPLE_WATCH_6_V_44_CELLULAR,
50
            'iPhone7,1' => DeviceProfile::APPLE_IPHONE_6_PLUS,
51
            'iPhone7,2' => DeviceProfile::APPLE_IPHONE_6,
52
            'iPhone8,1' => DeviceProfile::APPLE_IPHONE_6_S,
53
            'iPhone8,2' => DeviceProfile::APPLE_IPHONE_6_S_PLUS,
54
            'iPhone8,4' => DeviceProfile::APPLE_IPHONE_S_E,
55
            'iPhone9,1' => DeviceProfile::APPLE_IPHONE_7,
56
            'iPhone9,2' => DeviceProfile::APPLE_IPHONE_7_PLUS,
57
            'iPhone9,3' => DeviceProfile::APPLE_IPHONE_7,
58
            'iPhone9,4' => DeviceProfile::APPLE_IPHONE_7_PLUS,
59
            'iPhone10,1' => DeviceProfile::APPLE_IPHONE_8,
60
            'iPhone10,2' => DeviceProfile::APPLE_IPHONE_8_PLUS,
61
            'iPhone10,3' => DeviceProfile::APPLE_IPHONE_X_GLOBAL,
62
            'iPhone10,4' => DeviceProfile::APPLE_IPHONE_8,
63
            'iPhone10,5' => DeviceProfile::APPLE_IPHONE_8_PLUS,
64
            'iPhone10,6' => DeviceProfile::APPLE_IPHONE_X_G_S_M,
65
            'iPhone11,2' => DeviceProfile::APPLE_IPHONE_X_S,
66
            'iPhone11,4' => DeviceProfile::APPLE_IPHONE_X_S_MAX,
67
            'iPhone11,6' => DeviceProfile::APPLE_IPHONE_X_S_MAX_GLOBAL,
68
            'iPhone11,8' => DeviceProfile::APPLE_IPHONE_X_R,
69
            'iPhone12,1' => DeviceProfile::APPLE_IPHONE_11,
70
            'iPhone12,3' => DeviceProfile::APPLE_IPHONE_11_PRO,
71
            'iPhone12,5' => DeviceProfile::APPLE_IPHONE_11_PRO_MAX,
72
            'iPhone12,8' => DeviceProfile::APPLE_IPHONE_S_E_2,
73
            'iPhone13,1' => DeviceProfile::APPLE_IPHONE_12_MINI,
74
            'iPhone13,2' => DeviceProfile::APPLE_IPHONE_12,
75
            'iPhone13,3' => DeviceProfile::APPLE_IPHONE_12_PRO,
76
            'iPhone13,4' => DeviceProfile::APPLE_IPHONE_12_PRO_MAX,
77
            'Polar A370' => DeviceProfile::POLAR_A_370,
78
            'Polar M400' => DeviceProfile::POLAR_M_400,
79
            'Polar M430' => DeviceProfile::POLAR_M_430,
80
            'Polar M450' => DeviceProfile::POLAR_M_450,
81
            'Polar M460' => DeviceProfile::POLAR_M_460,
82
            'Polar M600' => DeviceProfile::POLAR_M_600,
83
            'Polar V800' => DeviceProfile::POLAR_V_800,
84
            'Polar Vantage V' => DeviceProfile::POLAR_VANTAGE_V,
85
            'Polar Vantage V Titan' => DeviceProfile::POLAR_VANTAGE_V_TITAN,
86
            'Polar Vantage M' => DeviceProfile::POLAR_VANTAGE_M,
87
            'Polar OH1' => DeviceProfile::POLAR_O_H_1,
88
            'Polar Ignite' => DeviceProfile::POLAR_IGNITE,
89
            'Polar Grit X' => DeviceProfile::POLAR_GRIT_X,
90
            'Runkeeper' => DeviceProfile::APP_RUNKEEPER,
91
            'Nike Run Club' => DeviceProfile::APP_NIKE_RUN_CLUB,
92
            'FitnessSyncer' => DeviceProfile::APP_FITNESS_SYNCER,
93
        ];
94
    }
95
96
    public function __construct()
97
    {
98
        $this->Mapping = $this->getMapping();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMapping() of type array<string,?> 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...
99
    }
100
101
    /**
102
     * @param  int|string $value
103
     * @return int|string
104
     */
105
    public function toInternal($value)
106
    {
107
        if (isset($this->Mapping[$value])) {
108
            return $this->Mapping[$value];
109
        }
110
111
        return;
112
    }
113
}
114