Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
TransferTaskSearchDTO
0.00% covered (danger)
0.00%
0 / 22
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 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 toArray
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 fromRequest
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Domain\TransferTask\DTOs;
4
5use Domain\Shared\Interfaces\DataTransferObjectInterface;
6use Illuminate\Foundation\Http\FormRequest;
7
8readonly class TransferTaskSearchDTO implements DataTransferObjectInterface
9{
10
11    public array $products;
12    public array $status;
13
14    public array $teams;
15    public array $creators;
16    public array $responsible;
17    public ?int $id;
18
19    public function __construct(array $args)
20    {
21        $this->id = $args['id'] ?? null;
22        $this->products = $args['products'] ?? [];
23        $this->status = $args['status'] ?? [];
24        $this->teams = $args['teams'] ?? [];
25        $this->creators = $args['creators'] ?? [];
26        $this->responsible = $args['responsible'] ?? [];
27    }
28
29    public function toArray(): array
30    {
31
32        return [
33            'id' => $this->id,
34            'products' => $this->products,
35            'status' => $this->status,
36            'teams' => $this->teams,
37            'creators' => $this->creators,
38            'responsible' => $this->responsible,
39        ];
40    }
41
42    public static function fromRequest(FormRequest $request): TransferTaskSearchDTO
43    {
44
45        return new self([
46            'id' => $request->validated('id'),
47            'products' => $request->validated('products'),
48            'status' => $request->validated('status'),
49            'teams' => $request->validated('teams'),
50            'creators' => $request->validated('creators'),
51            'responsible' => $request->validated('responsible'),
52        ]);
53    }
54}