Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| InvoiceAddItemConferenceDTO | |
0.00% |
0 / 10 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| toArray | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| fromRequest | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Invoice\DTOs; |
| 4 | |
| 5 | use App\Models\Product\Product; |
| 6 | use Domain\Shared\Interfaces\DataTransferObjectInterface; |
| 7 | use Illuminate\Foundation\Http\FormRequest; |
| 8 | |
| 9 | readonly final class InvoiceAddItemConferenceDTO implements DataTransferObjectInterface |
| 10 | { |
| 11 | public ?Product $product_id; |
| 12 | public ?float $product_amount; |
| 13 | |
| 14 | public function __construct(array $args) |
| 15 | { |
| 16 | $this->product_id = $args['product_id'] ?? null; |
| 17 | $this->product_amount = $args['product_amount'] ?? null; |
| 18 | } |
| 19 | |
| 20 | public function toArray(): array |
| 21 | { |
| 22 | return [ |
| 23 | 'product_id' => $this->product_id, |
| 24 | 'product_amount' => $this->product_amount, |
| 25 | ]; |
| 26 | } |
| 27 | |
| 28 | public static function fromRequest(FormRequest $request): InvoiceAddItemConferenceDTO |
| 29 | { |
| 30 | return new self([ |
| 31 | 'product_id' => Product::find($request->validated('product_id')), |
| 32 | 'product_amount' => $request->validated('product_amount'), |
| 33 | ]); |
| 34 | } |
| 35 | } |