Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 34
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
SeniorImportProductsDTO
0.00% covered (danger)
0.00%
0 / 34
0.00% covered (danger)
0.00%
0 / 4
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 toArray
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
2
 fromRequest
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
2
 fromArray
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Domain\Product\DTOs;
4
5use Domain\Shared\Interfaces\DataTransferObjectInterface;
6use Illuminate\Foundation\Http\FormRequest;
7
8final readonly class SeniorImportProductsDTO implements DataTransferObjectInterface
9{
10    public ?string $codemp;
11    public ?string $codder;
12    public ?string $codfam;
13    public ?string $codori;
14    public ?string $codpro;
15    public ?string $codref;
16    public ?string $datalt;
17
18
19    public function __construct(array $args)
20    {
21        $this->codemp = $args['codemp'] ?? null;
22        $this->codder = $args['codder'] ?? null;
23        $this->codfam = $args['codfam'] ?? null;
24        $this->codori = $args['codori'] ?? null;
25        $this->codpro = $args['codpro'] ?? null;
26        $this->codref = $args['codref'] ?? null;
27        $this->datalt = $args['datalt'] ?? null;
28    }
29
30    public function toArray(): array
31    {
32        return [
33            'codemp' => $this->codemp,
34            'codder' => $this->codder,
35            'codfam' => $this->codfam,
36            'codori' => $this->codori,
37            'codpro' => $this->codpro,
38            'codref' => $this->codref,
39            'datalt' => $this->datalt,
40        ];
41    }
42
43    public static function fromRequest(FormRequest $request): SeniorImportProductsDTO
44    {
45        return new self([
46            'codemp' => $request->validated('codemp'),
47            'codder' => $request->validated('codder'),
48            'codfam' => $request->validated('codfam'),
49            'codori' => $request->validated('codori'),
50            'codpro' => $request->validated('codpro'),
51            'codref' => $request->validated('codref'),
52            'datalt' => $request->validated('datalt'),
53        ]);
54    }
55
56    public static function fromArray(array $data): SeniorImportProductsDTO
57    {
58        return new self([
59            'codemp' => $data['codemp'] ?? null,
60            'codder' => $data['codder'] ?? null,
61            'codfam' => $data['codfam'] ?? null,
62            'codori' => $data['codori'] ?? null,
63            'codpro' => $data['codpro'] ?? null,
64            'codref' => $data['codref'] ?? null,
65            'datalt' => $data['datalt'] ?? null,
66        ]);
67    }
68}