Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 26
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
SeniorInvoiceImportDTO
0.00% covered (danger)
0.00%
0 / 26
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 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 toArray
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 fromRequest
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 fromArray
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Domain\Invoice\DTOs;
4
5use Domain\Shared\Interfaces\DataTransferObjectInterface;
6use Illuminate\Foundation\Http\FormRequest;
7
8final readonly class SeniorInvoiceImportDTO implements DataTransferObjectInterface
9{
10    public ?string $chvnel;
11    public ?int $codemp;
12    public ?int $codfil;
13    public ?string $datger;
14    public ?int $numnfc;
15
16    public function __construct(array $args)
17    {
18        $this->chvnel = $args['chvnel'] ?? null;
19        $this->codemp = $args['codemp'] ?? null;
20        $this->codfil = $args['codfil'] ?? null;
21        $this->datger = $args['datger'] ?? null;
22        $this->numnfc = $args['numnfc'] ?? null;
23    }
24
25    public function toArray(): array
26    {
27        return [
28            'chvNel' => $this->chvnel,
29            'codEmp' => $this->codemp,
30            'codFil' => $this->codfil,
31            'datGer' => $this->datger,
32            'numNfc' => $this->numnfc,
33        ];
34    }
35
36    public static function fromRequest(FormRequest $request): SeniorInvoiceImportDTO
37    {
38        return new self([
39            'chvnel' => $request->validated('chvnel'),
40            'codemp' => $request->validated('codemp'),
41            'codfil' => $request->validated('codfil'),
42            'datger' => $request->validated('datger'),
43            'numnfc' => $request->validated('numnfc'),
44        ]);
45    }
46
47    public static function fromArray(array $request): SeniorInvoiceImportDTO
48    {
49        return new self([
50            'chvnel' => $request['chvnel'] ?? null,
51            'codemp' => $request['codemp'] ?? null,
52            'codfil' => $request['codfil'] ?? null,
53            'datger' => $request['datger'] ?? null,
54            'numnfc' => $request['numnfc'] ?? null,
55        ]);
56    }   
57}