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