MakeCronTask::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 8
ccs 0
cts 7
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace MadWeb\Initializer\Jobs;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Foundation\Bus\Dispatchable;
7
8
class MakeCronTask
9
{
10
    use Dispatchable, Queueable;
11
12
    /**
13
     * Execute the job.
14
     *
15
     * @return string
16
     */
17
    public function handle()
18
    {
19
        $base_path = base_path();
20
        $task = "* * * * * cd $base_path && php artisan schedule:run >> /dev/null 2>&1";
21
        exec('(crontab -l 2>/dev/null; echo "'.$task.'") | crontab -');
22
23
        return 'Base cron task for scheduling work created. Task: '.$task;
24
    }
25
}
26