Completed
Branch add-test-cases (10aafb)
by Basenko
05:32
created

MakeCronTask::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 1
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 3
    public function handle()
18
    {
19 3
        $base_path = base_path();
20 3
        $task = '* * * * * php '.$base_path.'/artisan schedule:run >> /dev/null 2>&1';
21 3
        exec('(crontab -l 2>/dev/null; echo "'.$task.'") | crontab -');
22
23 3
        return 'Base cron task for scheduling work created. Task: '.$task;
24
    }
25
}
26