optimize technical truth

This commit is contained in:
team 1
2026-04-28 17:00:12 +02:00
parent 8d9f863143
commit bca015129c
5 changed files with 471 additions and 314 deletions

View File

@@ -201,6 +201,16 @@ final class ShopServiceConfig
return $this->int('scores.accessory_query_device_product_bonus', 10);
}
public function shouldFilterAccessoryProductsForDeviceQueries(): bool
{
return $this->bool('role_guard.filter_accessory_products_for_device_queries', true);
}
public function shouldKeepAmbiguousProductsForDeviceQueries(): bool
{
return $this->bool('role_guard.keep_ambiguous_products_for_device_queries', true);
}
public function getContainsDigitPattern(): string
{
return $this->string('patterns.contains_digit', '/\d/u');
@@ -343,6 +353,29 @@ final class ShopServiceConfig
return $this->string('deduplication.separator', '|');
}
private function bool(string $path, bool $default): bool
{
$value = $this->value($path, $default);
if (is_bool($value)) {
return $value;
}
if (is_scalar($value)) {
$normalized = strtolower(trim((string) $value));
if (in_array($normalized, ['1', 'true', 'yes', 'on'], true)) {
return true;
}
if (in_array($normalized, ['0', 'false', 'no', 'off'], true)) {
return false;
}
}
return $default;
}
private function int(string $path, int $default, int $min = PHP_INT_MIN): int
{
$value = $this->value($path, $default);