| 1 | <?php | 
  | 2 |  | 
  | 3 | require_once __DIR__ . "/BAD_REQUEST.php"; | 
  | 4 | require_once __DIR__ . "/recuperaEntero.php"; | 
  | 5 | require_once __DIR__ . "/ProblemDetails.php"; | 
  | 6 |  | 
  | 7 | function recuperaIdEntero(string $parametro): int | 
  | 8 | { | 
  | 9 |  | 
  | 10 |  $id = recuperaEntero($parametro); | 
  | 11 |  | 
  | 12 |  if ($id === false) | 
  | 13 |   throw new ProblemDetails( | 
  | 14 |    status: BAD_REQUEST, | 
  | 15 |    title: "Falta el id.", | 
  | 16 |    type: "/error/faltaid.html", | 
  | 17 |    detail: "La solicitud no tiene el valor de id.", | 
  | 18 |   ); | 
  | 19 |  | 
  | 20 |  if ($id === null) | 
  | 21 |   throw new ProblemDetails( | 
  | 22 |    status: BAD_REQUEST, | 
  | 23 |    title: "Id en blanco.", | 
  | 24 |    type: "/error/idenblanco.html", | 
  | 25 |   ); | 
  | 26 |  | 
  | 27 |  return $id; | 
  | 28 | } | 
  | 29 |  |