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