1 | <?php |
2 | |
3 | require_once __DIR__ . "/../../lib/php/ProblemDetails.php"; |
4 | |
5 | class Rol |
6 | { |
7 | |
8 | public string $id; |
9 | public string $descripcion; |
10 | |
11 | public function __construct(string $descripcion = "", string $id = "") |
12 | { |
13 | $this->id = $id; |
14 | $this->descripcion = $descripcion; |
15 | } |
16 | |
17 | public function valida() |
18 | { |
19 | |
20 | if ($this->id === "") |
21 | throw new ProblemDetails( |
22 | status: ProblemDetails::BadRequest, |
23 | type: "/error/faltaid.html", |
24 | title: "Falta el id.", |
25 | ); |
26 | |
27 | if ($this->descripcion === "") |
28 | throw new ProblemDetails( |
29 | status: ProblemDetails::BadRequest, |
30 | type: "/error/faltadescripcion.html", |
31 | title: "Falta la descripción.", |
32 | ); |
33 | } |
34 | } |
35 | |