TmuxUIStop   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 13
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 3
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Models\Settings;
6
use Blacklight\Tmux;
7
use Illuminate\Console\Command;
8
use Illuminate\Support\Facades\Process;
9
10
class TmuxUIStop extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'tmux-ui:stop {--k|kill : kill the session}';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Stop the processing of tmux scripts.';
25
26
    /**
27
     * @throws \Exception
28
     */
29
    public function handle(): void
30
    {
31
        $tmux = new Tmux;
32
        $tmux->stopIfRunning();
33
        if ($this->option('kill') === true) {
0 ignored issues
show
introduced by
The condition $this->option('kill') === true is always false.
Loading history...
34
            $sessionName = Settings::settingValue('tmux_session');
35
            $tmuxSession = Process::run('tmux kill-session -t '.$sessionName);
36
            $this->info('Killing active tmux session: '.$sessionName);
37
            if ($tmuxSession->successful()) {
38
                $this->info('Tmux session killed successfully');
39
            } else {
40
                $this->info('No valid tmux sessions found');
41
            }
42
        }
43
    }
44
}
45