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
SearchCostCenterDTO
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\CostCenter\DTOs;
4
5use Domain\Shared\Interfaces\DataTransferObjectInterface;
6
7use Illuminate\Foundation\Http\FormRequest;
8
9readonly final class SearchCostCenterDTO implements DataTransferObjectInterface
10{
11    public ?string $description;
12    public ?string $acronym;
13    public ?int $id;
14
15    public function __construct(array $args)
16    {
17        $this->description = $args['description'] ?? null;
18        $this->acronym     = $args['acronym'] ?? null;
19        $this->id          = $args['id'] ?? null;
20    }
21
22    public function toArray(): array
23    {
24        return [
25            'description' => $this->description,
26            'acronym'     => $this->acronym,
27            'id'          => $this->id,
28        ];
29    }
30
31    public static function fromRequest(FormRequest $request): SearchCostCenterDTO
32    {
33        return new self([
34            'description' => $request->validated('description'),
35            'acronym'     => $request->validated('acronym'),
36            'id'          => $request->validated('id'),
37        ]);
38    }
39}