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