TmuxUIStop::handle()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 12
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 0
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