| 1 | <?php |
| 2 | |
| 3 | require_once __DIR__ . "/BAD_REQUEST.php"; |
| 4 | require_once __DIR__ . "/recibeBytes.php"; |
| 5 | require_once __DIR__ . "/ProblemDetailsException.php"; |
| 6 | |
| 7 | function recibeBytesObligatorios(string $parametro) |
| 8 | { |
| 9 | $bytes = recibeBytes($parametro); |
| 10 | |
| 11 | if ($bytes === false) |
| 12 | throw new ProblemDetailsException([ |
| 13 | "status" => BAD_REQUEST, |
| 14 | "title" => "Falta el valor $parametro.", |
| 15 | "type" => "/errors/faltavalor.html", |
| 16 | "detail" => "La solicitud no tiene el valor de $parametro." |
| 17 | ]); |
| 18 | |
| 19 | if ($bytes === "") |
| 20 | throw new ProblemDetailsException([ |
| 21 | "status" => BAD_REQUEST, |
| 22 | "title" => "Archivo no seleccionado o vacío para el campo $parametro.", |
| 23 | "type" => "/errors/archivovacio.html", |
| 24 | "detail" => "Selecciona un archivo que no esté vacío en el campo $parametro." |
| 25 | ]); |
| 26 | |
| 27 | return $bytes; |
| 28 | } |
| 29 | |