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