1 | <?php |
2 | |
3 | require_once __DIR__ . "/../../lib/php/ProblemDetails.php"; |
4 | |
5 | class Pasatiempo |
6 | { |
7 | |
8 | public int $id; |
9 | public string $nombre; |
10 | |
11 | public function __construct(string $nombre = "", int $id = 0) |
12 | { |
13 | $this->id = $id; |
14 | $this->nombre = $nombre; |
15 | } |
16 | |
17 | public function valida() |
18 | { |
19 | if ($this->nombre === "") |
20 | throw new ProblemDetails( |
21 | status: ProblemDetails::BadRequest, |
22 | type: "/error/faltanombre.html", |
23 | title: "Falta el nombre.", |
24 | ); |
25 | } |
26 | } |
27 |