Completed
Push — master ( 6d7f70...76d437 )
by Michael
19s
created

DevelopmentFitSdkMapping::getMapping()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 61

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 61
ccs 0
cts 61
cp 0
rs 8.8509
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
            'iPhone7,1' => DeviceProfile::APPLE_IPHONE_6_PLUS,
43
            'iPhone7,2' => DeviceProfile::APPLE_IPHONE_6,
44
            'iPhone8,1' => DeviceProfile::APPLE_IPHONE_6_S,
45
            'iPhone8,2' => DeviceProfile::APPLE_IPHONE_6_S_PLUS,
46
            'iPhone8,4' => DeviceProfile::APPLE_IPHONE_S_E,
47
            'iPhone9,1' => DeviceProfile::APPLE_IPHONE_7,
48
            'iPhone9,2' => DeviceProfile::APPLE_IPHONE_7_PLUS,
49
            'iPhone9,3' => DeviceProfile::APPLE_IPHONE_7,
50
            'iPhone9,4' => DeviceProfile::APPLE_IPHONE_7_PLUS,
51
            'iPhone10,1' => DeviceProfile::APPLE_IPHONE_8,
52
            'iPhone10,2' => DeviceProfile::APPLE_IPHONE_8_PLUS,
53
            'iPhone10,3' => DeviceProfile::APPLE_IPHONE_X_GLOBAL,
54
            'iPhone10,4' => DeviceProfile::APPLE_IPHONE_8,
55
            'iPhone10,5' => DeviceProfile::APPLE_IPHONE_8_PLUS,
56
            'iPhone10,6' => DeviceProfile::APPLE_IPHONE_X_G_S_M,
57
            'iPhone11,2' => DeviceProfile::APPLE_IPHONE_X_S,
58
            'iPhone11,4' => DeviceProfile::APPLE_IPHONE_X_S_MAX,
59
            'iPhone11,6' => DeviceProfile::APPLE_IPHONE_X_S_MAX_GLOBAL,
60
            'iPhone11,8' => DeviceProfile::APPLE_IPHONE_X_R,
61
            'iPhone12,1' => DeviceProfile::APPLE_IPHONE_11,
62
            'iPhone12,3' => DeviceProfile::APPLE_IPHONE_11_PRO,
63
            'iPhone12,5' => DeviceProfile::APPLE_IPHONE_11_PRO_MAX,
64
            'iPhone12,8' => DeviceProfile::APPLE_IPHONE_S_E_2,
65
            'Polar A370' => DeviceProfile::POLAR_A_370,
66
            'Polar M400' => DeviceProfile::POLAR_M_400,
67
            'Polar M430' => DeviceProfile::POLAR_M_430,
68
            'Polar M450' => DeviceProfile::POLAR_M_450,
69
            'Polar M460' => DeviceProfile::POLAR_M_460,
70
            'Polar M600' => DeviceProfile::POLAR_M_600,
71
            'Polar V800' => DeviceProfile::POLAR_V_800,
72
            'Polar Vantage V' => DeviceProfile::POLAR_VANTAGE_V,
73
            'Polar Vantage V Titan' => DeviceProfile::POLAR_VANTAGE_V_TITAN,
74
            'Polar Vantage M' => DeviceProfile::POLAR_VANTAGE_M,
75
            'Polar OH1' => DeviceProfile::POLAR_O_H_1,
76
            'Polar Ignite' => DeviceProfile::POLAR_IGNITE,
77
            'Polar Grit X' => DeviceProfile::POLAR_GRIT_X,
78
            'Runkeeper' => DeviceProfile::APP_RUNKEEPER,
79
            'Nike Run Club' => DeviceProfile::APP_NIKE_RUN_CLUB,
80
        ];
81
    }
82
83
    public function __construct()
84
    {
85
        $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...
86
    }
87
88
    /**
89
     * @param  int|string $value
90
     * @return int|string
91
     */
92
    public function toInternal($value)
93
    {
94
        if (isset($this->Mapping[$value])) {
95
            return $this->Mapping[$value];
96
        }
97
98
        return;
99
    }
100
}
101