Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
17 / 17 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| RequestDevolutionDTO | |
100.00% |
17 / 17 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| fromRequest | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Request\DTOs; |
| 4 | |
| 5 | use Illuminate\Foundation\Http\FormRequest; |
| 6 | |
| 7 | use Domain\Shared\Interfaces\DataTransferObjectInterface; |
| 8 | |
| 9 | readonly final class RequestDevolutionDTO implements DataTransferObjectInterface |
| 10 | { |
| 11 | public string $applicant_badge; |
| 12 | public ?string $applicant_name; |
| 13 | public array $stock_io_products; |
| 14 | public ?string $observation; |
| 15 | |
| 16 | public function __construct(array $args) |
| 17 | { |
| 18 | $this->applicant_badge = $args['applicant_badge']; |
| 19 | $this->applicant_name = $args['applicant_name'] ?? null; |
| 20 | $this->stock_io_products = $args['stock_io_products']; |
| 21 | $this->observation = $args['observation'] ?? null; |
| 22 | } |
| 23 | |
| 24 | public function toArray(): array |
| 25 | { |
| 26 | return [ |
| 27 | 'applicant' => [ |
| 28 | 'badge' => $this->applicant_badge, |
| 29 | 'name' => $this->applicant_name, |
| 30 | ], |
| 31 | 'observation' => $this->observation, |
| 32 | ]; |
| 33 | } |
| 34 | |
| 35 | public static function fromRequest(FormRequest $request): RequestDevolutionDTO |
| 36 | { |
| 37 | return new self([ |
| 38 | 'applicant_badge' => $request->validated('applicant_badge'), |
| 39 | 'applicant_name' => $request->validated('applicant_name'), |
| 40 | 'stock_io_products' => $request->validated('stock_io_products'), |
| 41 | 'observation' => $request->validated('observation'), |
| 42 | ]); |
| 43 | } |
| 44 | } |