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