This commit is contained in:
43
api/app/Enums/Ambulatorio/FeridaExsudato.php
Normal file
43
api/app/Enums/Ambulatorio/FeridaExsudato.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user