Skip to content

Commit 280ef2e

Browse files
ISSUE #1865: Improve milestone comparisons
1 parent 6151396 commit 280ef2e

File tree

38 files changed

+600
-467
lines changed

38 files changed

+600
-467
lines changed

config/reference.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,17 @@
10981098
* doctrine?: DoctrineConfig,
10991099
* doctrine_migrations?: DoctrineMigrationsConfig,
11001100
* twig?: TwigConfig,
1101+
* "when@dev"?: array{
1102+
* imports?: ImportsConfig,
1103+
* parameters?: ParametersConfig,
1104+
* services?: ServicesConfig,
1105+
* framework?: FrameworkConfig,
1106+
* flysystem?: FlysystemConfig,
1107+
* monolog?: MonologConfig,
1108+
* doctrine?: DoctrineConfig,
1109+
* doctrine_migrations?: DoctrineMigrationsConfig,
1110+
* twig?: TwigConfig,
1111+
* },
11011112
* "when@prod"?: array{
11021113
* imports?: ImportsConfig,
11031114
* parameters?: ParametersConfig,
@@ -1203,6 +1214,7 @@ public static function config(array $config): array
12031214
* deprecated?: array{package:string, version:string, message?:string},
12041215
* }
12051216
* @psalm-type RoutesConfig = array{
1217+
* "when@dev"?: array<string, RouteConfig|ImportConfig|AliasConfig>,
12061218
* "when@prod"?: array<string, RouteConfig|ImportConfig|AliasConfig>,
12071219
* "when@test"?: array<string, RouteConfig|ImportConfig|AliasConfig>,
12081220
* ...<string, RouteConfig|ImportConfig|AliasConfig>

src/Domain/Milestone/FunComparison/ActivityCountFunComparison.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,64 @@
88

99
enum ActivityCountFunComparison: string implements FunComparison
1010
{
11+
case ONE_PER_WEEK_TWO_MONTHS = 'countOnePerWeekTwoMonths';
12+
case ONE_PER_WEEK_HALF_YEAR = 'countOnePerWeekHalfYear';
1113
case WEEKLY_FOR_YEAR = 'countWeeklyForYear';
1214
case TWICE_WEEKLY_FOR_YEAR = 'countTwiceWeeklyForYear';
1315
case FIVE_WEEKLY_FOR_YEAR = 'countFiveWeeklyForYear';
14-
case DAILY_FOR_YEAR = 'countDailyForYear';
1516
case TWICE_WEEKLY_FOR_FIVE_YEARS = 'countTwiceWeeklyForFiveYears';
1617
case THREE_WEEKLY_FOR_FIVE_YEARS = 'countThreeWeeklyForFiveYears';
1718
case THREE_WEEKLY_FOR_SEVEN_YEARS = 'countThreeWeeklyForSevenYears';
1819
case FOUR_WEEKLY_FOR_SEVEN_YEARS = 'countFourWeeklyForSevenYears';
1920
case FIVE_WEEKLY_FOR_SEVEN_YEARS = 'countFiveWeeklyForSevenYears';
2021
case DAILY_FOR_SEVEN_YEARS = 'countDailyForSevenYears';
22+
case DAILY_FOR_EIGHT_YEARS = 'countDailyForEightYears';
23+
case DAILY_FOR_ELEVEN_YEARS = 'countDailyForElevenYears';
2124
case DAILY_FOR_FOURTEEN_YEARS = 'countDailyForFourteenYears';
25+
case DAILY_FOR_TWENTY_YEARS = 'countDailyForTwentyYears';
2226
case DAILY_FOR_TWENTYSEVEN_YEARS = 'countDailyForTwentysevenYears';
2327

2428
public static function resolve(int $count): ?self
2529
{
2630
return match (true) {
2731
$count >= 10_000 => self::DAILY_FOR_TWENTYSEVEN_YEARS,
32+
$count >= 7_500 => self::DAILY_FOR_TWENTY_YEARS,
2833
$count >= 5_000 => self::DAILY_FOR_FOURTEEN_YEARS,
34+
$count >= 4_000 => self::DAILY_FOR_ELEVEN_YEARS,
35+
$count >= 3_000 => self::DAILY_FOR_EIGHT_YEARS,
2936
$count >= 2_500 => self::DAILY_FOR_SEVEN_YEARS,
3037
$count >= 2_000 => self::FIVE_WEEKLY_FOR_SEVEN_YEARS,
3138
$count >= 1_500 => self::FOUR_WEEKLY_FOR_SEVEN_YEARS,
3239
$count >= 1_000 => self::THREE_WEEKLY_FOR_SEVEN_YEARS,
3340
$count >= 750 => self::THREE_WEEKLY_FOR_FIVE_YEARS,
3441
$count >= 500 => self::TWICE_WEEKLY_FOR_FIVE_YEARS,
35-
$count >= 365 => self::DAILY_FOR_YEAR,
3642
$count >= 250 => self::FIVE_WEEKLY_FOR_YEAR,
3743
$count >= 100 => self::TWICE_WEEKLY_FOR_YEAR,
3844
$count >= 50 => self::WEEKLY_FOR_YEAR,
45+
$count >= 25 => self::ONE_PER_WEEK_HALF_YEAR,
46+
$count >= 10 => self::ONE_PER_WEEK_TWO_MONTHS,
3947
default => null,
4048
};
4149
}
4250

4351
public function trans(TranslatorInterface $translator, ?string $locale = null): string
4452
{
4553
return match ($this) {
54+
self::ONE_PER_WEEK_TWO_MONTHS => $translator->trans("That's about one activity per week for two months", locale: $locale),
55+
self::ONE_PER_WEEK_HALF_YEAR => $translator->trans("That's about one activity per week for half a year", locale: $locale),
4656
self::WEEKLY_FOR_YEAR => $translator->trans("That's about one activity per week for a year", locale: $locale),
4757
self::TWICE_WEEKLY_FOR_YEAR => $translator->trans("That's almost 2 activities per week for a year", locale: $locale),
4858
self::FIVE_WEEKLY_FOR_YEAR => $translator->trans("That's nearly 5 activities per week for a year", locale: $locale),
49-
self::DAILY_FOR_YEAR => $translator->trans("That's more than one activity per day for a year", locale: $locale),
5059
self::TWICE_WEEKLY_FOR_FIVE_YEARS => $translator->trans("That's 2 activities per week for nearly 5 years", locale: $locale),
5160
self::THREE_WEEKLY_FOR_FIVE_YEARS => $translator->trans("That's 3 activities per week for nearly 5 years", locale: $locale),
5261
self::THREE_WEEKLY_FOR_SEVEN_YEARS => $translator->trans("That's almost 3 activities per week for 7 years", locale: $locale),
5362
self::FOUR_WEEKLY_FOR_SEVEN_YEARS => $translator->trans("That's nearly 4 activities per week for 7 years", locale: $locale),
5463
self::FIVE_WEEKLY_FOR_SEVEN_YEARS => $translator->trans("That's more than 5 activities per week for 7 years", locale: $locale),
5564
self::DAILY_FOR_SEVEN_YEARS => $translator->trans("That's an activity every day for almost 7 years", locale: $locale),
65+
self::DAILY_FOR_EIGHT_YEARS => $translator->trans("That's an activity every day for over 8 years", locale: $locale),
66+
self::DAILY_FOR_ELEVEN_YEARS => $translator->trans("That's an activity every day for nearly 11 years", locale: $locale),
5667
self::DAILY_FOR_FOURTEEN_YEARS => $translator->trans("That's an activity every day for nearly 14 years", locale: $locale),
68+
self::DAILY_FOR_TWENTY_YEARS => $translator->trans("That's an activity every day for over 20 years", locale: $locale),
5769
self::DAILY_FOR_TWENTYSEVEN_YEARS => $translator->trans("That's an activity almost every day for 27 years", locale: $locale),
5870
};
5971
}

src/Domain/Milestone/FunComparison/DistanceFunComparison.php

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,67 +9,79 @@
99

1010
enum DistanceFunComparison: string implements FunComparison
1111
{
12-
case CENTURY_RIDE = 'distanceCenturyRide';
13-
case NETHERLANDS_LENGTH = 'distanceNetherlandsLength';
14-
case AMSTERDAM_BERLIN_RETURN = 'distanceAmsterdamBerlinReturn';
12+
case EDGE_OF_SPACE = 'distanceEdgeOfSpace';
13+
case LENGTH_OF_JAMAICA = 'distanceLengthOfJamaica';
14+
case MADRID_TO_BARCELONA = 'distanceMadridToBarcelona';
1515
case FRANCE_LENGTH = 'distanceFranceLength';
16-
case GREAT_BRITAIN_LENGTH = 'distanceGreatBritainLength';
17-
case RHINE_RIVER = 'distanceRhineRiver';
18-
case WIDER_THAN_AUSTRALIA = 'distanceWiderThanAustralia';
16+
case DANUBE_RIVER = 'distanceDanubeRiver';
1917
case GREAT_WALL_OF_CHINA = 'distanceGreatWallOfChina';
20-
case USA_COAST_TO_COAST = 'distanceUsaCoastToCoast';
21-
case TRANS_SIBERIAN_RAILWAY = 'distanceTransSiberianRailway';
22-
case EARTH_DIAMETER = 'distanceEarthDiameter';
18+
case QUARTER_AROUND_EARTH = 'distanceQuarterAroundEarth';
19+
case LONDON_TO_PERTH = 'distanceLondonToPerth';
2320
case HALFWAY_AROUND_EARTH = 'distanceHalfwayAroundEarth';
21+
case CIRCUMFERENCE_OF_MARS = 'distanceCircumferenceOfMars';
22+
case THREE_QUARTERS_AROUND_EARTH = 'distanceThreeQuartersAroundEarth';
2423
case EARTH_CIRCUMFERENCE = 'distanceEarthCircumference';
25-
case TWICE_AROUND_EARTH = 'distanceTwiceAroundEarth';
24+
case DIAMETER_OF_NEPTUNE = 'distanceDiameterOfNeptune';
25+
case NEARLY_TWICE_AROUND_EARTH = 'distanceNearlyTwiceAroundEarth';
2626
case TWO_AND_HALF_TIMES_AROUND_EARTH = 'distanceTwoAndHalfTimesAroundEarth';
27+
case DIAMETER_OF_JUPITER = 'distanceDiameterOfJupiter';
28+
case FIVE_TIMES_AROUND_EARTH = 'distanceFiveTimesAroundEarth';
29+
case SPEED_OF_LIGHT_PER_SECOND = 'distanceSpeedOfLightPerSecond';
2730
case EARTH_TO_MOON = 'distanceEarthToMoon';
31+
case MORE_THAN_EARTH_TO_MOON = 'distanceMoreThanEarthToMoon';
2832

2933
public static function resolve(Kilometer $distance): ?self
3034
{
3135
$km = $distance->toFloat();
3236

3337
return match (true) {
34-
$km >= 384_400 => self::EARTH_TO_MOON,
38+
$km >= 500_000 => self::MORE_THAN_EARTH_TO_MOON,
39+
$km >= 400_000 => self::EARTH_TO_MOON,
40+
$km >= 300_000 => self::SPEED_OF_LIGHT_PER_SECOND,
41+
$km >= 200_000 => self::FIVE_TIMES_AROUND_EARTH,
42+
$km >= 150_000 => self::DIAMETER_OF_JUPITER,
3543
$km >= 100_000 => self::TWO_AND_HALF_TIMES_AROUND_EARTH,
36-
$km >= 80_000 => self::TWICE_AROUND_EARTH,
37-
$km >= 40_075 => self::EARTH_CIRCUMFERENCE,
38-
$km >= 20_038 => self::HALFWAY_AROUND_EARTH,
39-
$km >= 12_742 => self::EARTH_DIAMETER,
40-
$km >= 9_288 => self::TRANS_SIBERIAN_RAILWAY,
41-
$km >= 6_671 => self::USA_COAST_TO_COAST,
44+
$km >= 75_000 => self::NEARLY_TWICE_AROUND_EARTH,
45+
$km >= 50_000 => self::DIAMETER_OF_NEPTUNE,
46+
$km >= 40_000 => self::EARTH_CIRCUMFERENCE,
47+
$km >= 30_000 => self::THREE_QUARTERS_AROUND_EARTH,
48+
$km >= 25_000 => self::CIRCUMFERENCE_OF_MARS,
49+
$km >= 20_000 => self::HALFWAY_AROUND_EARTH,
50+
$km >= 15_000 => self::LONDON_TO_PERTH,
51+
$km >= 10_000 => self::QUARTER_AROUND_EARTH,
4252
$km >= 5_000 => self::GREAT_WALL_OF_CHINA,
43-
$km >= 3_500 => self::WIDER_THAN_AUSTRALIA,
44-
$km >= 2_300 => self::RHINE_RIVER,
45-
$km >= 1_400 => self::GREAT_BRITAIN_LENGTH,
53+
$km >= 2_500 => self::DANUBE_RIVER,
4654
$km >= 1_000 => self::FRANCE_LENGTH,
47-
$km >= 600 => self::AMSTERDAM_BERLIN_RETURN,
48-
$km >= 300 => self::NETHERLANDS_LENGTH,
49-
$km >= 100 => self::CENTURY_RIDE,
55+
$km >= 500 => self::MADRID_TO_BARCELONA,
56+
$km >= 250 => self::LENGTH_OF_JAMAICA,
57+
$km >= 100 => self::EDGE_OF_SPACE,
5058
default => null,
5159
};
5260
}
5361

5462
public function trans(TranslatorInterface $translator, ?string $locale = null): string
5563
{
5664
return match ($this) {
57-
self::CENTURY_RIDE => $translator->trans("That's a century ride", locale: $locale),
58-
self::NETHERLANDS_LENGTH => $translator->trans("That's the length of the Netherlands from north to south", locale: $locale),
59-
self::AMSTERDAM_BERLIN_RETURN => $translator->trans("That's the distance from Amsterdam to Berlin and back", locale: $locale),
65+
self::EDGE_OF_SPACE => $translator->trans("That's the distance to the edge of space, straight up", locale: $locale),
66+
self::LENGTH_OF_JAMAICA => $translator->trans("That's roughly the length of the island of Jamaica", locale: $locale),
67+
self::MADRID_TO_BARCELONA => $translator->trans("That's roughly the distance from Madrid to Barcelona", locale: $locale),
6068
self::FRANCE_LENGTH => $translator->trans("That's roughly the length of France", locale: $locale),
61-
self::GREAT_BRITAIN_LENGTH => $translator->trans("That's the length of Great Britain from north to south", locale: $locale),
62-
self::RHINE_RIVER => $translator->trans("That's the length of the Rhine river", locale: $locale),
63-
self::WIDER_THAN_AUSTRALIA => $translator->trans("That's wider than Australia", locale: $locale),
69+
self::DANUBE_RIVER => $translator->trans("That's roughly the length of the Danube river", locale: $locale),
6470
self::GREAT_WALL_OF_CHINA => $translator->trans("That's the length of the Great Wall of China", locale: $locale),
65-
self::USA_COAST_TO_COAST => $translator->trans("That's the width of the United States coast to coast", locale: $locale),
66-
self::TRANS_SIBERIAN_RAILWAY => $translator->trans("That's the length of the Trans-Siberian Railway", locale: $locale),
67-
self::EARTH_DIAMETER => $translator->trans("That's the diameter of the Earth", locale: $locale),
71+
self::QUARTER_AROUND_EARTH => $translator->trans("That's roughly a quarter of the way around the Earth", locale: $locale),
72+
self::LONDON_TO_PERTH => $translator->trans("That's roughly the distance from London to Perth", locale: $locale),
6873
self::HALFWAY_AROUND_EARTH => $translator->trans("That's more than halfway around the Earth", locale: $locale),
74+
self::CIRCUMFERENCE_OF_MARS => $translator->trans("That's more than the circumference of Mars", locale: $locale),
75+
self::THREE_QUARTERS_AROUND_EARTH => $translator->trans("That's three quarters of the way around the Earth", locale: $locale),
6976
self::EARTH_CIRCUMFERENCE => $translator->trans("That's the circumference of the Earth", locale: $locale),
70-
self::TWICE_AROUND_EARTH => $translator->trans("That's twice around the Earth", locale: $locale),
77+
self::DIAMETER_OF_NEPTUNE => $translator->trans("That's roughly the diameter of Neptune", locale: $locale),
78+
self::NEARLY_TWICE_AROUND_EARTH => $translator->trans("That's nearly twice around the Earth", locale: $locale),
7179
self::TWO_AND_HALF_TIMES_AROUND_EARTH => $translator->trans("That's more than 2.5 times around the Earth", locale: $locale),
80+
self::DIAMETER_OF_JUPITER => $translator->trans("That's roughly the diameter of Jupiter", locale: $locale),
81+
self::FIVE_TIMES_AROUND_EARTH => $translator->trans("That's five times around the Earth", locale: $locale),
82+
self::SPEED_OF_LIGHT_PER_SECOND => $translator->trans("That's roughly the distance light travels in one second", locale: $locale),
7283
self::EARTH_TO_MOON => $translator->trans("That's the distance from Earth to the Moon", locale: $locale),
84+
self::MORE_THAN_EARTH_TO_MOON => $translator->trans("That's more than the distance from Earth to the Moon", locale: $locale),
7385
};
7486
}
7587
}

0 commit comments

Comments
 (0)