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