1 | <?php |
2 | |
3 | require_once __DIR__ . "/../../lib/php/ProblemDetails.php"; |
4 | |
5 | class Archivo |
6 | { |
7 | |
8 | public int $id; |
9 | public string $bytes; |
10 | |
11 | public function __construct(string $bytes = "", int $id = 0) |
12 | { |
13 | $this->id = $id; |
14 | $this->bytes = $bytes; |
15 | } |
16 | |
17 | public function valida() |
18 | { |
19 | if ($this->bytes === "") |
20 | throw new ProblemDetails( |
21 | status: ProblemDetails::BadRequest, |
22 | type: "/error/archivovacio.html", |
23 | title: "Archivo vacío.", |
24 | detail: "Selecciona un archivo que no esté vacío." |
25 | ); |
26 | } |
27 | } |
28 | |