$options Mutated in place on success. * @param array $postData * @param string $fieldName The field key in both $postData and $options. * @param string $alreadyTranslatedErrorMessage Built with __('literal', '404-solution') at the call site. * @param int $minValue Minimum permitted value (inclusive in the default mode, exclusive in absint-strict mode). * @param bool $useAbsintForCheck When true, requires absint($value) > $minValue. When false, requires raw value >= $minValue. * @return string Empty string on success, or the translated error suffixed with ".
". */ public function validateAndSetNumericField( array &$options, array $postData, string $fieldName, string $alreadyTranslatedErrorMessage, int $minValue = 0, bool $useAbsintForCheck = false ): string { if (!isset($postData[$fieldName])) { return ''; } $value = $postData[$fieldName]; $scalarValue = is_scalar($value) ? $value : 0; if ($useAbsintForCheck) { $passes = is_numeric($value) && absint($scalarValue) > $minValue; } else { $passes = is_numeric($value) && $value >= $minValue; } if ($passes) { $options[$fieldName] = absint($scalarValue); return ''; } return $alreadyTranslatedErrorMessage . '.
'; } }