Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 34 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| SearchStockInputDTO | |
0.00% |
0 / 34 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
| toArray | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
2 | |||
| fromRequest | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\StockIO\DTOs; |
| 4 | |
| 5 | use Carbon\Carbon; |
| 6 | use Domain\Shared\Interfaces\DataTransferObjectInterface; |
| 7 | use Domain\Shared\Traits\DateRangeDTOTrait; |
| 8 | use Illuminate\Foundation\Http\FormRequest; |
| 9 | |
| 10 | final readonly class SearchStockInputDTO implements DataTransferObjectInterface |
| 11 | { |
| 12 | use DateRangeDTOTrait; |
| 13 | |
| 14 | public ?int $id; |
| 15 | public ?string $integrationProduct; |
| 16 | public ?string $integrationDerivation; |
| 17 | public ?string $integrationBarcode; |
| 18 | public ?string $integrationCode; |
| 19 | public ?string $integrationCompany; |
| 20 | public ?string $productionOrder; |
| 21 | public ?string $description; |
| 22 | public ?int $page; |
| 23 | |
| 24 | /** @var null|Carbon[] */ |
| 25 | public ?array $movementDate; |
| 26 | |
| 27 | public function __construct(array $args) |
| 28 | { |
| 29 | $this->id = $args['id'] ?? null; |
| 30 | $this->integrationProduct = $args['integration_product'] ?? null; |
| 31 | $this->integrationDerivation = $args['integration_derivation'] ?? null; |
| 32 | $this->integrationBarcode = $args['integration_barcode'] ?? null; |
| 33 | $this->integrationCompany = $args['integration_company'] ?? null; |
| 34 | $this->integrationCode = $args['integration_code'] ?? null; |
| 35 | $this->productionOrder = $args['production_order'] ?? null; |
| 36 | $this->description = $args['description'] ?? null; |
| 37 | $this->movementDate = $args['movement_date'] ?? null; |
| 38 | $this->page = $args['page'] ?? 1; |
| 39 | } |
| 40 | |
| 41 | public function toArray(): array |
| 42 | { |
| 43 | return [ |
| 44 | 'id' => $this->id, |
| 45 | 'integration_product' => $this->integrationProduct, |
| 46 | 'integration_derivation' => $this->integrationDerivation, |
| 47 | 'integration_barcode' => $this->integrationBarcode, |
| 48 | 'integration_company' => $this->integrationCompany, |
| 49 | 'integration_code' => $this->integrationCode, |
| 50 | 'production_order' => $this->productionOrder, |
| 51 | 'description' => $this->description, |
| 52 | 'movement_date' => $this->movementDate, |
| 53 | 'page' => $this->page, |
| 54 | ]; |
| 55 | } |
| 56 | |
| 57 | public static function fromRequest(FormRequest $request): SearchStockInputDTO |
| 58 | { |
| 59 | return new self([ |
| 60 | 'id' => $request->validated('id'), |
| 61 | 'integration_product' => $request->validated('integration_product'), |
| 62 | 'integration_derivation' => $request->validated('integration_derivation'), |
| 63 | 'integration_barcode' => $request->validated('integration_barcode'), |
| 64 | 'integration_company' => $request->validated('integration_company'), |
| 65 | 'integration_code' => $request->validated('integration_code'), |
| 66 | 'production_order' => $request->validated('production_order'), |
| 67 | 'description' => $request->validated('description'), |
| 68 | 'movement_date' => self::processDate($request->validated('movement_date')), |
| 69 | 'page' => $request->validated('page'), |
| 70 | ]); |
| 71 | } |
| 72 | } |