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
|
|
|
/** @var int[]|string[] */ |
19
|
|
|
protected $Mapping = []; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @return array |
23
|
|
|
*/ |
24
|
1 |
|
protected function getMapping() |
25
|
|
|
{ |
26
|
|
|
return [ |
27
|
1 |
|
'neorun' => DeviceProfile::APP_EPSON_NEO_RUN, |
28
|
1 |
|
'kompass' => DeviceProfile::APP_KOMPASS, |
29
|
1 |
|
'runtastic' => DeviceProfile::APP_RUNTASTIC, |
30
|
1 |
|
'smashrun' => DeviceProfile::APP_SMASHRUN, |
31
|
1 |
|
'trails' => DeviceProfile::APP_TRAILS, |
32
|
1 |
|
'sports tracker' => DeviceProfile::APP_SPORTS_TRACKER, |
33
|
1 |
|
'runkeeper' => DeviceProfile::APP_RUNKEEPER, |
34
|
1 |
|
'runmeter' => DeviceProfile::APP_RUNMETER, |
35
|
1 |
|
'decathlon' => DeviceProfile::APP_DECATHLON_COACH, |
36
|
1 |
|
'endomondo' => DeviceProfile::APP_ENDOMONDO, |
37
|
1 |
|
'ismoothrun' => DeviceProfile::APP_I_SMOOTH_RUN, |
38
|
1 |
|
'strava' => DeviceProfile::APP_STRAVA, |
39
|
1 |
|
'trailrunner' => DeviceProfile::APP_TRAIL_RUNNER, |
40
|
1 |
|
'run.gps' => DeviceProfile::APP_RUN_GPS_TRAINER, |
41
|
1 |
|
'osmand' => DeviceProfile::APP_OSM_AND, |
42
|
1 |
|
'locus map' => DeviceProfile::APP_LOCUS_MAP, |
43
|
1 |
|
'endomondo' => DeviceProfile::APP_ENDOMONDO, |
44
|
1 |
|
'polar flow' => DeviceProfile::APP_POLAR_FLOW, |
45
|
1 |
|
'sportractive' => DeviceProfile::APP_SPORTRACTIVE, |
46
|
1 |
|
'oruxmaps' => DeviceProfile::APP_ORUX_MAPS, |
47
|
1 |
|
'komoot' => DeviceProfile::APP_KOMOOT, |
48
|
1 |
|
'navime' => DeviceProfile::APP_NAVIME, |
49
|
1 |
|
'http://www.polarpersonaltrainer.com' => DeviceProfile::APP_POLAR_PERSONAL_TRAINER, |
50
|
1 |
|
'a-rival' => DeviceProfile::ARIVAL_UNKNOWN, |
51
|
1 |
|
'rungap' => DeviceProfile::APP_RUN_GAP, |
52
|
1 |
|
'globalsat' => DeviceProfile::APP_GLOBAL_SAT, |
53
|
1 |
|
'garmin connect' => DeviceProfile::APP_GARMIN_CONNECT, |
54
|
1 |
|
'outdooractive' => DeviceProfile::APP_OUTDOOR_ACTIVE, |
55
|
1 |
|
]; |
56
|
|
|
} |
57
|
|
|
|
58
|
1 |
|
public function __construct() |
59
|
|
|
{ |
60
|
1 |
|
$this->Mapping = $this->getMapping(); |
61
|
1 |
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param int|string $creator |
65
|
|
|
* @return int|string |
66
|
|
|
*/ |
67
|
1 |
|
public function toInternal($creator) |
68
|
|
|
{ |
69
|
1 |
|
foreach ($this->Mapping as $startsWith => $id) { |
70
|
1 |
|
if (strtolower(substr($creator, 0, strlen($startsWith))) === $startsWith) { |
|
|
|
|
71
|
1 |
|
return $id; |
72
|
|
|
} |
73
|
1 |
|
} |
74
|
|
|
|
75
|
1 |
|
return null; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|