1 | <?php |
||||
2 | |||||
3 | namespace BeyondCode\LaravelWebSockets\Console\Commands; |
||||
4 | |||||
5 | use BeyondCode\LaravelWebSockets\Facades\StatisticsStore; |
||||
6 | use Illuminate\Console\Command; |
||||
7 | |||||
8 | class CleanStatistics extends Command |
||||
9 | { |
||||
10 | /** |
||||
11 | * The name and signature of the console command. |
||||
12 | * |
||||
13 | * @var string |
||||
14 | */ |
||||
15 | protected $signature = 'websockets:clean |
||||
16 | {appId? : (optional) The app id that will be cleaned.} |
||||
17 | {--days= : Delete records older than this amount of days since now.} |
||||
18 | '; |
||||
19 | |||||
20 | /** |
||||
21 | * The console command description. |
||||
22 | * |
||||
23 | * @var string|null |
||||
24 | */ |
||||
25 | protected $description = 'Clean up old statistics from the WebSocket statistics storage.'; |
||||
26 | |||||
27 | /** |
||||
28 | * Run the command. |
||||
29 | * |
||||
30 | * @return void |
||||
31 | */ |
||||
32 | public function handle() |
||||
33 | { |
||||
34 | $this->comment('Cleaning WebSocket Statistics...'); |
||||
35 | |||||
36 | $days = $this->option('days') ?: config('statistics.delete_statistics_older_than_days'); |
||||
37 | |||||
38 | $amountDeleted = StatisticsStore::delete( |
||||
39 | now()->subDays($days), $this->argument('appId') |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() It seems like
$this->argument('appId') can also be of type array ; however, parameter $appId of BeyondCode\LaravelWebSoc...atisticsStore::delete() does only seem to accept integer|null|string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
40 | ); |
||||
41 | |||||
42 | $this->info("Deleted {$amountDeleted} record(s) from the WebSocket statistics storage."); |
||||
43 | } |
||||
44 | } |
||||
45 |