major update

This commit is contained in:
2026-03-04 15:56:58 +01:00
parent 16759a2732
commit 8f4dd5840d
478 changed files with 24313 additions and 8201 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace MintyPHP\Domain\Taxonomy;
trait SupportsStringTaxonomy
{
/**
* @return list<string>
*/
public static function values(): array
{
return array_map(
static fn (self $case): string => $case->value,
self::cases()
);
}
public static function tryNormalize(string $value): ?self
{
$value = strtolower(trim($value));
if ($value === '') {
return null;
}
foreach (self::cases() as $case) {
if (strtolower($case->value) === $value) {
return $case;
}
}
return null;
}
public static function normalizeOr(string $value, self $fallback): self
{
return self::tryNormalize($value) ?? $fallback;
}
}