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