Files
rkm-conectasus-ci-sandbox/api/app/Enums/Ambulatorio/FeridaExsudato.php
Antonio Lopes dos Santos afec302c3e
All checks were successful
build-api-image / build (push) Successful in 51s
init commit
2026-08-04 16:52:02 -03:00

43 lines
1.1 KiB
PHP

<?php
namespace App\Enums\Ambulatorio;
final class FeridaExsudato
{
public const ESCASSO = 1;
public const BAIXO = 2;
public const MEDIO = 3;
public const ALTO = 4;
public static function fromDescricao(?string $descricao): ?int
{
if ($descricao === null) {
return null;
}
$norm = self::normalize($descricao);
$map = [
'escasso' => self::ESCASSO,
'baixo' => self::BAIXO,
'medio' => self::MEDIO,
'médio' => self::MEDIO,
'alto' => self::ALTO,
];
return $map[$norm] ?? null;
}
private static function normalize(string $text): string
{
$text = trim(mb_strtolower($text));
$text = str_replace(
['á','à','ã','â','ä','é','è','ê','ë','í','ì','î','ï','ó','ò','õ','ô','ö','ú','ù','û','ü','ç'],
['a','a','a','a','a','e','e','e','e','i','i','i','i','o','o','o','o','o','u','u','u','u','c'],
$text
);
return preg_replace('/\s+/', ' ', $text);
}
}