Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
88.24% covered (warning)
88.24%
15 / 17
50.00% covered (danger)
50.00%
2 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
SeniorProcessInvoiceItemDivisionDTO
88.24% covered (warning)
88.24%
15 / 17
50.00% covered (danger)
50.00%
2 / 4
4.03
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
 toArray
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
 fromRequest
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 fromArray
0.00% covered (danger)
0.00%
0 / 1
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 SeniorProcessInvoiceItemDivisionDTO implements DataTransferObjectInterface
9{
10    public int $codEmp;
11
12    public int $codFil;
13
14    public string $chvNel;
15
16    public int $seqIpc;
17
18    public array $itens;
19
20    public function __construct(array $args)
21    {
22        $this->codEmp = (int) $args['codEmp'];
23        $this->codFil = (int) $args['codFil'];
24        $this->chvNel = $args['chvNel'];
25        $this->seqIpc = (int) $args['seqIpc'];
26        $this->itens = array_map(
27            fn (array $item) => ['qtdIte' => (float) $item['qtdIte']],
28            $args['itens']
29        );
30    }
31
32    public function toArray(): array
33    {
34        return [
35            'codEmp' => $this->codEmp,
36            'codFil' => $this->codFil,
37            'chvNel' => $this->chvNel,
38            'seqIpc' => $this->seqIpc,
39            'itens' => $this->itens,
40        ];
41    }
42
43    public static function fromRequest(FormRequest $request): SeniorProcessInvoiceItemDivisionDTO
44    {
45        return new self($request->validated());
46    }
47
48    public static function fromArray(array $request): SeniorProcessInvoiceItemDivisionDTO
49    {
50        return new self($request);
51    }
52}