Passed
Pull Request — master (#30)
by Mostafa
11:18
created

DebounceRefresh::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 0
c 1
b 0
f 1
dl 0
loc 6
rs 10
cc 1
nc 1
nop 4
1
<?php
2
3
namespace Mostafaznv\LaraCache\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 Illuminate\Support\Facades\Cache;
11
12
13
class DebounceRefresh implements ShouldQueue
14
{
15
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
0 ignored issues
show
introduced by
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by Mostafaznv\LaraCache\Jobs\DebounceRefresh: $collectionClass, $id, $relations, $class, $keyBy
Loading history...
16
17
    public function __construct(
18
        public string     $key,
19
        public string     $token,
20
        public string     $model,
21
        public string $name,
22
    ) {}
23
24
25
    public function handle(): void
26
    {
27
        $latestToken = Cache::get($this->key);
28
29
        if ($latestToken !== $this->token) {
30
            return;
31
        }
32
33
        app($this->model)->cache()->update($this->name);
34
    }
35
}
36