Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
50.00% covered (warning)
50.00%
1 / 2
CRAP
22.22% covered (danger)
22.22%
2 / 9
DemonLauncher
0.00% covered (danger)
0.00%
0 / 1
50.00% covered (warning)
50.00%
1 / 2
7.23
22.22% covered (danger)
22.22%
2 / 9
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 handle
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 7
1<?php
2
3namespace Qmp\Laravel\CommandsLaravel\Console\Commands;
4
5use Illuminate\Console\Command;
6
7class DemonLauncher extends Command
8{
9    /**
10     * The name and signature of the console command.
11     *
12     * @var string
13     */
14    protected $signature = 'demon:launcher {artisanCommand} {--delay=10}';
15
16    /**
17     * The console command description.
18     *
19     * @var string
20     */
21    protected $description = 'Launch a demon that execute the given command';
22
23    /**
24     * The artisan command that will be run
25     *
26     * @var string
27     */
28    protected $command;
29
30    /**
31     * The delay between each command call
32     *
33     * @var string
34     */
35    protected $delay;
36
37    /**
38     * Create a new command instance.
39     *
40     * @return void
41     */
42    public function __construct()
43    {
44        parent::__construct();
45    }
46
47    /**
48     * Execute the console command.
49     *
50     * @return mixed
51     */
52    public function handle()
53    {
54        $this->command = $this->argument('artisanCommand');
55        $this->delay = (int) $this->option('delay');
56
57        while(true) {
58            $this->info('call : ' . $this->command);
59            $this->call($this->command);
60            sleep($this->delay);
61        }
62    }
63}