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