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