Skip to content

Commit

Permalink
prepare Polar Vantage M3 + minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
laufhannes committed Dec 12, 2024
1 parent b9c143e commit afe0373
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
vendor/
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
composer.lock
.idea
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
"psr-4": {
"Runalyze\\Devices\\": "src/"
}
},
"scripts": {
"phpunit": "phpunit",
"php-cs-fixer": "php-cs-fixer fix"
}
}
3 changes: 2 additions & 1 deletion src/Device/DeviceProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ class DeviceProfile extends AbstractEnum
public const GARMIN_LILY_2_ACTIVE = 694;
public const SIGMA_SPORT_ROX_121_EVO = 695;
public const GARMIN_ETREX_SOLAR = 696;
public const POLAR_VANTAGE_M_3 = 697;

public static function getSlugs(): array
{
Expand All @@ -729,7 +730,7 @@ public static function getSlugs(): array

public static function getSlug(
#[ExpectedValues(valuesFromClass: self::class)]
int $enum
int $enum,
): string {
self::generateSlugsArray();

Expand Down
37 changes: 37 additions & 0 deletions src/Device/PolarVantageM3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
* This file is part of the Runalyze Device List.
*
* (c) RUNALYZE <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Runalyze\Devices\Device;

class PolarVantageM3 extends AbstractDevice
{
use PolarDeviceTrait;

public function getEnum(): int
{
return DeviceProfile::POLAR_VANTAGE_M_3;
}

public function getName(): string
{
return 'Vantage M3';
}

public function hasBarometer(): bool
{
return true;
}

public function getReleaseDate(): ?\DateTimeInterface
{
return new \DateTimeImmutable('2024-10-23');
}
}
2 changes: 1 addition & 1 deletion src/Distributor/DistributorProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function getSlugs(): array

public static function getSlug(
#[ExpectedValues(valuesFromClass: self::class)]
int $enum
int $enum,
): string {
self::generateSlugsArray();

Expand Down
2 changes: 1 addition & 1 deletion src/Distributor/Garmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public function getDeviceEnumList(): array
DeviceProfile::GARMIN_EDGE_1050,
DeviceProfile::GARMIN_LILY_2,
DeviceProfile::GARMIN_LILY_2_ACTIVE,
DeviceProfile::GARMIN_ETREX_SOLAR
DeviceProfile::GARMIN_ETREX_SOLAR,
];
}
}
1 change: 1 addition & 0 deletions src/Distributor/Polar.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function getDeviceEnumList(): array
DeviceProfile::POLAR_V_800,
DeviceProfile::POLAR_VANTAGE_M,
DeviceProfile::POLAR_VANTAGE_M_2,
DeviceProfile::POLAR_VANTAGE_M_3,
DeviceProfile::POLAR_VANTAGE_V,
DeviceProfile::POLAR_VANTAGE_V_TITAN,
DeviceProfile::POLAR_GRIT_X,
Expand Down
18 changes: 5 additions & 13 deletions src/Mapping/PolarFitSdkMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

class PolarFitSdkMapping
{
/** @var int[]|string[] */
protected $Mapping = [];
/** @var int[] */
protected array $Mapping = [];

protected function getMapping()
protected function getMapping(): array
{
return [
1 => DeviceProfile::POLAR_LOOP,
Expand Down Expand Up @@ -63,16 +63,8 @@ public function __construct()
$this->Mapping = $this->getMapping();
}

/**
* @param int|string $value
* @return int|string
*/
public function toInternal($value)
public function toInternal($value): ?int
{
if (isset($this->Mapping[$value])) {
return $this->Mapping[$value];
}

return;
return $this->Mapping[$value] ?? null;
}
}

0 comments on commit afe0373

Please sign in to comment.