Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
TeamSearchDTO
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 toArray
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 fromRequest
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Domain\Team\DTOs;
4
5use Illuminate\Foundation\Http\FormRequest;
6
7use Domain\Shared\Interfaces\DataTransferObjectInterface;
8
9readonly final class TeamSearchDTO implements DataTransferObjectInterface
10{
11    public ?string $description;
12    public ?int $id;
13    public ?int $user;
14
15    public function __construct(array $args)
16    {
17        $this->description = $args['description'] ?? null;
18        $this->id          = $args['id'] ?? null;
19        $this->user        = $args['user'] ?? null;
20    }
21
22    public function toArray(): array
23    {
24        return [
25            'description' => $this->description,
26            'id'          => $this->id,
27            'user_id'     => $this->user,
28        ];
29    }
30
31    public static function fromRequest(FormRequest $request): TeamSearchDTO
32    {
33        return new self([
34            'description' => $request->validated('description'),
35            'id'          => $request->validated('id'),
36            'user'        => $request->validated('user'),
37        ]);
38    }
39}