Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
IntegrationUpdateService
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 update
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace Domain\Integration\Services;
4
5use App\Events\ServiceProcessed;
6use App\Models\Integration\Integration;
7use App\Models\User;
8use Domain\Shared\Interfaces\DataTransferObjectInterface;
9
10class IntegrationUpdateService
11{
12    public function update(DataTransferObjectInterface $integrationDTO, Integration $integration, User $user): Integration
13    {
14        $integration->setAttribute('parameters', $integrationDTO->toArray());
15        if ($integration->isDirty()) {
16            $integration->save();
17        }
18
19        ServiceProcessed::dispatch(self::class, $user);
20        return $integration;
21    }
22}