Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| StockIOProductDeleteService | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| delete | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\StockIO\Services; |
| 4 | |
| 5 | use App\Events\ServiceProcessed; |
| 6 | use App\Models\StockIO\StockIOProduct; |
| 7 | use App\Models\Integration\Integration; |
| 8 | use App\Models\User; |
| 9 | use Illuminate\Support\Facades\DB; |
| 10 | use Throwable; |
| 11 | |
| 12 | readonly class StockIOProductDeleteService |
| 13 | { |
| 14 | /** |
| 15 | * @param StockIOProduct $stockIOProduct |
| 16 | * @param User $user |
| 17 | * @return void |
| 18 | * @throws Throwable |
| 19 | */ |
| 20 | public function delete(StockIOProduct $stockIOProduct, Integration $integration, User $user): void |
| 21 | { |
| 22 | try { |
| 23 | DB::beginTransaction(); |
| 24 | |
| 25 | $integration->delete(); |
| 26 | $stockIOProduct->delete(); |
| 27 | |
| 28 | DB::commit(); |
| 29 | } catch (Throwable $throwable) { |
| 30 | DB::rollBack(); |
| 31 | throw $throwable; |
| 32 | } |
| 33 | |
| 34 | ServiceProcessed::dispatch(self::class, $user); |
| 35 | } |
| 36 | } |