Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| ShippingPackagingSearchDTO | |
0.00% |
0 / 25 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| toArray | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| fromRequest | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\ShippingPackaging\DTOs; |
| 4 | |
| 5 | use App\Models\Customer\Customer; |
| 6 | use Carbon\Carbon; |
| 7 | use Domain\Shared\Interfaces\DataTransferObjectInterface; |
| 8 | use Domain\Shared\Traits\DateRangeDTOTrait; |
| 9 | use Domain\ShippingPackaging\Enums\ShippingPackagingStatusEnum; |
| 10 | use Domain\ShippingPackaging\Enums\ShippingPackagingTypeEnum; |
| 11 | use Illuminate\Foundation\Http\FormRequest; |
| 12 | |
| 13 | final readonly class ShippingPackagingSearchDTO implements DataTransferObjectInterface |
| 14 | { |
| 15 | use DateRangeDTOTrait; |
| 16 | |
| 17 | /** @var ShippingPackagingStatusEnum[] */ |
| 18 | public array $status; |
| 19 | /** @var ShippingPackagingTypeEnum[] */ |
| 20 | public array $type; |
| 21 | public ?array $createdAt; |
| 22 | public ?string $codcli; |
| 23 | public ?string $numane; |
| 24 | public ?string $numpfa; |
| 25 | public ?int $id; |
| 26 | |
| 27 | public function __construct(array $args) |
| 28 | { |
| 29 | $this->status = $args['status'] ?? []; |
| 30 | $this->type = $args['type'] ?? []; |
| 31 | $this->createdAt = $args['created_at'] ?? null; |
| 32 | $this->codcli = $args['codcli'] ?? null; |
| 33 | $this->numpfa = $args['numpfa'] ?? null; |
| 34 | $this->numane = $args['numane'] ?? null; |
| 35 | $this->id = $args['id'] ?? null; |
| 36 | } |
| 37 | |
| 38 | public function toArray(): array |
| 39 | { |
| 40 | return [ |
| 41 | 'id' => $this->id, |
| 42 | 'customer' => $this->codcli, |
| 43 | 'status' => $this->status, |
| 44 | 'type' => $this->type, |
| 45 | 'numane' => $this->numane, |
| 46 | 'numpfa' => $this->numpfa, |
| 47 | 'created_at' => $this->createdAt, |
| 48 | ]; |
| 49 | } |
| 50 | |
| 51 | public static function fromRequest(FormRequest $request): ShippingPackagingSearchDTO |
| 52 | { |
| 53 | return new self([ |
| 54 | 'id' => $request->validated('id'), |
| 55 | 'status' => $request->validated('status'), |
| 56 | 'type' => $request->validated('type'), |
| 57 | 'created_at' => self::processDate($request->validated('created_at')), |
| 58 | 'codcli' => $request->validated('codcli'), |
| 59 | 'numane' => $request->validated('numane'), |
| 60 | 'numpfa' => $request->validated('numpfa'), |
| 61 | ]); |
| 62 | } |
| 63 | } |