| 1 | <?php |
| 2 | |
| 3 | require_once __DIR__ . "/BAD_REQUEST.php"; |
| 4 | require_once __DIR__ . "/recibeFlotante.php"; |
| 5 | require_once __DIR__ . "/ProblemDetailsException.php"; |
| 6 | |
| 7 | function recibeFlotanteObligatorio(string $parametro) |
| 8 | { |
| 9 | $flotante = recibeFlotante($parametro); |
| 10 | |
| 11 | if ($flotante === false) |
| 12 | throw new ProblemDetailsException([ |
| 13 | "status" => BAD_REQUEST, |
| 14 | "title" => "Falta el valor $parametro.", |
| 15 | "type" => "/error/faltavalor.html", |
| 16 | "detail" => "La solicitud no tiene el valor de $parametro." |
| 17 | ]); |
| 18 | |
| 19 | if ($flotante === null) |
| 20 | throw new ProblemDetailsException([ |
| 21 | "status" => BAD_REQUEST, |
| 22 | "title" => "Campo $parametro en blanco.", |
| 23 | "type" => "/error/camponumericoenblanco.html", |
| 24 | "detail" => "Pon un número en el campo $parametro." |
| 25 | ]); |
| 26 | |
| 27 | return $flotante; |
| 28 | } |
| 29 | |