Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
ProcessUserInfoAsyncJob | |
0.00% |
0 / 10 |
|
0.00% |
0 / 5 |
56 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
handle | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
backoff | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
created | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
updated | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace App\Jobs; |
4 | |
5 | use Illuminate\Bus\Queueable; |
6 | use Illuminate\Contracts\Queue\ShouldQueue; |
7 | use Illuminate\Foundation\Bus\Dispatchable; |
8 | use Illuminate\Queue\InteractsWithQueue; |
9 | use Illuminate\Queue\SerializesModels; |
10 | use App\Http\Models\UserInfo; |
11 | use App\Http\Services\StatisticsService; |
12 | use App\Services\UserInfo\UserInfoService; |
13 | |
14 | class ProcessUserInfoAsyncJob implements ShouldQueue |
15 | { |
16 | use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; |
17 | |
18 | public $tries = 5; |
19 | |
20 | public function __construct( |
21 | public UserInfo $user, |
22 | public string $action |
23 | ) {} |
24 | |
25 | public function handle(): void |
26 | { |
27 | if ($this->action === 'created') { |
28 | $this->created($this->user); |
29 | } elseif ($this->action === 'updated') { |
30 | $this->created($this->user); |
31 | } |
32 | } |
33 | |
34 | public function backoff() |
35 | { |
36 | return [10, 30, 60, 120, 300]; |
37 | } |
38 | |
39 | private function created(UserInfo $user): void |
40 | { |
41 | $subscriptionService = new UserInfoService(new StatisticsService()); |
42 | |
43 | $subscriptionService->created($user); |
44 | } |
45 | |
46 | private function updated(UserInfo $user): void |
47 | { |
48 | $subscriptionService = new UserInfoService(new StatisticsService()); |
49 | |
50 | $subscriptionService->updated($user); |
51 | } |
52 | } |