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