Kernel   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A commands() 0 5 1
A schedule() 0 12 3
A horizonSnapshot() 0 4 1
A pruneFailedJobs() 0 6 1
1
<?php
2
3
namespace App\Console;
4
5
use Illuminate\Console\Scheduling\Schedule;
6
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7
use Illuminate\Support\Facades\App;
8
9
class Kernel extends ConsoleKernel
10
{
11
    protected $commands = [];
12
13
    private Schedule $schedule;
14
15
    protected function schedule(Schedule $schedule)
16
    {
17
        if (App::runningUnitTests()) {
18
            return;
19
        }
20
21
        $this->schedule = $schedule;
22
23
        $this->pruneFailedJobs()
24
            ->horizonSnapshot();
25
26
        if (App::isProduction()) {
27
        }
28
    }
29
30
    protected function commands()
31
    {
32
        $this->load(__DIR__.'/Commands');
33
34
        require base_path('routes/console.php');
35
    }
36
37
    private function pruneFailedJobs(): self
38
    {
39
        $this->schedule->command('queue:prune-failed', ['--hours' => 7 * 24])
40
            ->weekly();
41
42
        return $this;
43
    }
44
45
    private function horizonSnapshot(): void
46
    {
47
        $this->schedule->command('horizon:snapshot')
48
            ->everyFiveMinutes();
49
    }
50
}
51