Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
63.16% covered (warning)
63.16%
12 / 19
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
IntegrationStockInputWarehouseProductDTO
63.16% covered (warning)
63.16%
12 / 19
66.67% covered (warning)
66.67%
2 / 3
3.45
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 toArray
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
 fromRequest
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Domain\Integration\DTOs;
4
5use Domain\Shared\Interfaces\DataTransferObjectInterface;
6use Illuminate\Foundation\Http\FormRequest;
7
8readonly final class IntegrationStockInputWarehouseProductDTO implements DataTransferObjectInterface
9{
10    public string $invoice_key;
11    public string $product_code;
12    public string $derivation_code;
13    public string $quantity_movement;
14    public string $sequence_movement;
15
16    public function __construct(array $args)
17    {
18        $this->invoice_key       = $args['invoice_key'];
19        $this->product_code      = $args['product_code'];
20        $this->derivation_code   = $args['derivation_code'];
21        $this->quantity_movement = $args['quantity_movement'];
22        $this->sequence_movement = $args['sequence_movement'];
23    }
24
25    public function toArray(): array
26    {
27        return [
28            'invoice_key'       => $this->invoice_key,
29            'product_code'      => $this->product_code,
30            'derivation_code'   => $this->derivation_code,
31            'quantity_movement' => $this->quantity_movement,
32            'sequence_movement' => $this->sequence_movement,
33        ];
34    }
35
36    public static function fromRequest(FormRequest $request): IntegrationStockInputWarehouseProductDTO
37    {
38        return new self([
39            'invoice_key'       => $request->validated('invoice_key'),
40            'product_code'      => $request->validated('product_code'),
41            'derivation_code'   => $request->validated('derivation_code'),
42            'quantity_movement' => $request->validated('quantity_movement'),
43            'sequence_movement' => $request->validated('sequence_movement'),
44        ]);
45    }
46}