1. srv / modelo / leePasatiempo.php

1<?php
2
3require_once __DIR__ . "/Pasatiempo.php";
4
5function leePasatiempo($objeto)
6{
7
8 if (!isset($objeto->nombre) || !is_string($objeto->nombre))
9 throw new ProblemDetails(
10 status: ProblemDetails::BadRequest,
11 type: "/error/nombreincorrecto.html",
12 title: "El nombre debe ser texto.",
13 );
14
15 if (!isset($objeto->uuid) || !is_string($objeto->uuid))
16 throw new ProblemDetails(
17 status: ProblemDetails::BadRequest,
18 type: "/error/uuidincorrecto.html",
19 title: "El uuid debe ser texto.",
20 );
21
22 if (!isset($objeto->eliminado) || !is_bool($objeto->eliminado))
23 throw new ProblemDetails(
24 status: ProblemDetails::BadRequest,
25 type: "/error/eliminadoincorrecto.html",
26 title: "El campo eliminado debe ser booleano.",
27 );
28
29 if (!isset($objeto->modificacion) || !is_int($objeto->modificacion))
30 throw new ProblemDetails(
31 status: ProblemDetails::BadRequest,
32 type: "/error/modificacionincorrecta.html",
33 title: "La modificacion debe ser número.",
34 );
35
36 return new Pasatiempo(
37 uuid: $objeto->uuid,
38 nombre: $objeto->nombre,
39 modificacion: $objeto->modificacion,
40 eliminado: $objeto->eliminado
41 );
42}
43
skip_previous skip_next