Kernel::horizonSnapshot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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