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