Completed
Push — master ( a6dbad...4886a1 )
by Michael
01:33
created

NameMapping::getEnum()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 5
nc 3
nop 1
crap 3
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 NameMapping
17
{
18
    public static $mappingArray = [
19
        'neorun' => DeviceProfile::APP_EPSON_NEO_RUN,
20
        'kompass' => DeviceProfile::APP_KOMPASS,
21
        'runtastic' => DeviceProfile::APP_RUNTASTIC,
22
        'smashrun' => DeviceProfile::APP_SMASHRUN,
23
        'trails' => DeviceProfile::APP_TRAILS,
24
        'sports tracker' => DeviceProfile::APP_SPORTS_TRACKER,
25
        'runkeeper' => DeviceProfile::APP_RUNKEEPER,
26
        'runmeter' => DeviceProfile::APP_RUNMETER,
27
        'decathlon' => DeviceProfile::APP_DECATHLON_COACH,
28
        'endomondo' => DeviceProfile::APP_ENDOMONDO,
29
        'ismoothrun' => DeviceProfile::APP_I_SMOOTH_RUN,
30
        'strava' => DeviceProfile::APP_STRAVA,
31
        'trailrunner' => DeviceProfile::APP_TRAIL_RUNNER,
32
        'run.gps' => DeviceProfile::APP_RUN_GPS_TRAINER,
33
        'osmand' => DeviceProfile::APP_OSM_AND,
34
        'locus map' => DeviceProfile::APP_LOCUS_MAP,
35
        'endomondo' => DeviceProfile::APP_ENDOMONDO,
36
        'polar flow' => DeviceProfile::APP_POLAR_FLOW,
37
        'sportractive' => DeviceProfile::APP_SPORTRACTIVE,
38
        'oruxmaps' => DeviceProfile::APP_ORUX_MAPS,
39
        'komoot' => DeviceProfile::APP_KOMOOT,
40
        'navime' => DeviceProfile::APP_NAVIME,
41
        'http://www.polarpersonaltrainer.com' => DeviceProfile::APP_POLAR_PERSONAL_TRAINER,
42
        'a-rival' => DeviceProfile::ARIVAL_UNKNOWN,
43
    ];
44
45
    /**
46
     * @param  string   $creator
47
     * @return int|null
48
     */
49 1
    public static function getEnum($creator)
50
    {
51 1
        foreach (self::$mappingArray as $startsWith => $id) {
52 1
            if (strtolower(substr($creator, 0, strlen($startsWith))) === $startsWith) {
53 1
                return $id;
54
            }
55 1
        }
56
57 1
        return null;
58
    }
59
}
60