Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
UserResponse | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
jsonSerialize | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace App\Response; |
6 | |
7 | use App\Entity\User; |
8 | use JsonSerializable; |
9 | |
10 | class UserResponse implements JsonSerializable |
11 | { |
12 | public function __construct(public readonly User $user) |
13 | { |
14 | } |
15 | |
16 | public function jsonSerialize(): array |
17 | { |
18 | return [ |
19 | 'id' => $this->user->getId(), |
20 | 'name' => $this->user->getName(), |
21 | 'email' => $this->user->getEmail(), |
22 | 'createdAt' => $this->user->getCreatedAtString(), |
23 | 'updatedAt' => $this->user->getUpdatedAtString(), |
24 | ]; |
25 | } |
26 | } |