Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| ItemStorageDTO | |
0.00% |
0 / 18 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| toArray | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| fromRequest | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Item\DTOs; |
| 4 | |
| 5 | use App\Models\Storage\Storage; |
| 6 | use Domain\Integration\DTOs\IntegrationItemDTO; |
| 7 | use Domain\Shared\Interfaces\DataTransferObjectInterface; |
| 8 | use Illuminate\Foundation\Http\FormRequest; |
| 9 | |
| 10 | readonly final class ItemStorageDTO implements DataTransferObjectInterface |
| 11 | { |
| 12 | public Storage $storage; |
| 13 | public float $amount; |
| 14 | public IntegrationItemDTO $integrationItemDTO; |
| 15 | |
| 16 | public function __construct(array $args) |
| 17 | { |
| 18 | $this->storage = $args['storage']; |
| 19 | $this->amount = $args['amount']; |
| 20 | $this->integrationItemDTO = new IntegrationItemDTO([ |
| 21 | 'production_order' => $args['production_order'], |
| 22 | 'movement_date' => $args['movement_date'], |
| 23 | ]); |
| 24 | } |
| 25 | |
| 26 | public function toArray(): array |
| 27 | { |
| 28 | return [ |
| 29 | 'storage_id' => $this->storage->getKey(), |
| 30 | 'amount' => $this->amount, |
| 31 | 'production_order' => $this->integrationItemDTO->productionOrder, |
| 32 | 'movement_date' => $this->integrationItemDTO->movementDate, |
| 33 | ]; |
| 34 | } |
| 35 | |
| 36 | public static function fromRequest(FormRequest $request): ItemStorageDTO |
| 37 | { |
| 38 | return new self([ |
| 39 | 'storage' => Storage::find($request->validated('id')), |
| 40 | 'amount' => $request->validated('amount'), |
| 41 | 'production_order' => $request->validated('production_order'), |
| 42 | 'movement_date' => $request->validated('movement_date'), |
| 43 | ]); |
| 44 | } |
| 45 | } |