chore: code cleanup

This commit is contained in:
fromme committed 2026-09-17 16:10:34 +02:00
1 parent 1a3640b15c
commit 5a01054b0e
65 files changed
+1046 -795

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace App\Routing;
/**
* The Y-m-d day identifier that every board route speaks.
*/
final class DateParam
{
/** Route requirement, so a malformed day 404s instead of silently falling back to today. */
public const PATTERN = '\d{4}-\d{2}-\d{2}';
public static function parse(?string $value): ?\DateTimeImmutable
{
if (null === $value || '' === $value) {
return null;
}
// The leading "!" resets the time part, so the result is midnight rather than "now".
$date = \DateTimeImmutable::createFromFormat('!Y-m-d', $value);
return false === $date ? null : $date;
}
public static function parseOrToday(?string $value): \DateTimeImmutable
{
return self::parse($value) ?? new \DateTimeImmutable('today');
}
}