Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ConversionStoreService | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| store | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Conversion\Services; |
| 4 | |
| 5 | use App\Events\ServiceProcessed; |
| 6 | use App\Models\Conversion\Conversion; |
| 7 | use App\Models\User; |
| 8 | use Domain\Integration\Services\IntegrationStoreService; |
| 9 | use Domain\Conversion\DTOs\StoreConversionDTO; |
| 10 | |
| 11 | readonly class ConversionStoreService |
| 12 | { |
| 13 | public function store(StoreConversionDTO $storeConversionDTO, User $user): Conversion |
| 14 | { |
| 15 | $conversion = new Conversion(); |
| 16 | $conversion->fill($storeConversionDTO->toArray()); |
| 17 | $conversion->unitMeasurementFrom()->associate($storeConversionDTO->unitMeasurementFrom); |
| 18 | $conversion->unitMeasurementTo()->associate($storeConversionDTO->unitMeasurementTo); |
| 19 | $conversion->setAttribute('type', $storeConversionDTO->type); |
| 20 | $conversion->save(); |
| 21 | |
| 22 | (new IntegrationStoreService())->store($storeConversionDTO->integration, $conversion, $user); |
| 23 | |
| 24 | ServiceProcessed::dispatch(self::class, $user); |
| 25 | return $conversion; |
| 26 | } |
| 27 | } |