Completed
Pull Request — master (#4)
by Michael
01:31
created

FitMapping::getGarminDevice()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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
class FitMapping
15
{
16
    public static function guessDevice($manufactorId, $productId)
17
    {
18
        switch ($manufactorId) {
19
            case 1:
20
                return self::getGarminDevice($productId);
21
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
22
            case 23:
23
                return self::getSuuntoDevice($productId);
24
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
25
            case 294:
26
                return self::getCorosDevice($productId);
27
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
28
            case 32:
29
                return self::getWahooDevice($productId);
30
            default:
31
                return null;
32
        }
33
    }
34
35
    public function getGarminDevice($productId)
36
    {
37
        $garmin = new GarminFitSdkMapping();
38
39
        return $garmin->toInternal($productId);
40
    }
41
42
    public function getCorosDevice($productId)
43
    {
44
        $coros = new CorosFitSdkMapping();
45
46
        return $coros->toInternal($productId);
47
    }
48
49
    public function getSuuntoDevice($productId)
50
    {
51
        $suunto = new SuuntoFitSdkMapping();
52
53
        return $suunto->toInternal($productId);
54
    }
55
56
    public function getWahooDevice($productId)
57
    {
58
        $suunto = new WahooFitSdkMapping();
59
60
        return $suunto->toInternal($productId);
61
    }
62
}
63