Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| SearchPurchaseOrderDTO | |
0.00% |
0 / 16 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| 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\PurchaseOrder\DTOs; |
| 4 | |
| 5 | use Carbon\Carbon; |
| 6 | use Domain\Shared\Interfaces\DataTransferObjectInterface; |
| 7 | use Illuminate\Foundation\Http\FormRequest; |
| 8 | |
| 9 | readonly final class SearchPurchaseOrderDTO implements DataTransferObjectInterface |
| 10 | { |
| 11 | public ?int $id; |
| 12 | public ?string $codfor; |
| 13 | public ?Carbon $created_at; |
| 14 | public ?Carbon $updated_at; |
| 15 | |
| 16 | public function __construct(array $args) |
| 17 | { |
| 18 | $this->id = $args['id'] ?? null; |
| 19 | $this->codfor = $args['codfor'] ?? null; |
| 20 | $this->created_at = $args['created_at'] ? Carbon::parse($args['created_at']) : null; |
| 21 | $this->updated_at = $args['updated_at'] ? Carbon::parse($args['updated_at']) : null; |
| 22 | } |
| 23 | |
| 24 | public function toArray(): array |
| 25 | { |
| 26 | return [ |
| 27 | 'id' => $this->id, |
| 28 | 'codfor' => $this->codfor, |
| 29 | 'created_at' => $this->created_at->toDateString(), |
| 30 | 'updated_at' => $this->updated_at->toDateString(), |
| 31 | ]; |
| 32 | } |
| 33 | |
| 34 | public static function fromRequest(FormRequest $request): SearchPurchaseOrderDTO |
| 35 | { |
| 36 | return new self([ |
| 37 | 'id' => $request->validated('id'), |
| 38 | 'codfor' => $request->validated('codfor'), |
| 39 | 'created_at' => $request->validated('created_at'), |
| 40 | 'updated_at' => $request->validated('updated_at'), |
| 41 | ]); |
| 42 | } |
| 43 | } |