forked from robiningelbrecht/statistics-for-strava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatsContext.php
More file actions
61 lines (53 loc) · 1.54 KB
/
StatsContext.php
File metadata and controls
61 lines (53 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1);
namespace App\Domain\Dashboard;
use Symfony\Contracts\Translation\TranslatableInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
enum StatsContext: string implements TranslatableInterface
{
case MOVING_TIME = 'movingTime';
case DISTANCE = 'distance';
case ELEVATION = 'elevation';
case LOAD = 'load';
public function trans(TranslatorInterface $translator, ?string $locale = null): string
{
return match ($this) {
self::MOVING_TIME => $translator->trans('Time', locale: $locale),
self::DISTANCE => $translator->trans('Distance', locale: $locale),
self::ELEVATION => $translator->trans('Elevation', locale: $locale),
self::LOAD => $translator->trans('Load', locale: $locale),
};
}
public function getSvgIcon(): string
{
return match ($this) {
self::MOVING_TIME => 'time',
self::DISTANCE => 'distance',
self::ELEVATION => 'elevation',
self::LOAD => 'load',
};
}
/**
* @return StatsContext[]
*/
public static function defaultSortingOrder(): array
{
return [
self::DISTANCE,
self::MOVING_TIME,
self::ELEVATION,
self::LOAD,
];
}
/**
* @return StatsContext[]
*/
public static function defaultChartSortingOrder(): array
{
return [
self::DISTANCE,
self::MOVING_TIME,
self::ELEVATION,
];
}
}