Completed
Push — main ( b591cd...5346a3 )
by Tan
15s queued 13s
created

ChangeOwnerConfigJson   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 31
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 3
1
<?php
2
3
namespace CSlant\LaravelTelegramGitNotifier\Commands;
4
5
use Illuminate\Console\Command;
6
7
class ChangeOwnerConfigJson extends Command
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'config-json:change-owner 
15
                {user : The user to change owner}
16
                {group? : The group to change owner}';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'config-json';
24
25
    /**
26
     * Execute the console command.
27
     *
28
     * @return void
29
     */
30
    public function handle(): void
31
    {
32
        $user = $this->argument('user');
33
        $group = $this->argument('group') ?? $user;
34
35
        $jsonsPath = config('telegram-git-notifier.data_file.storage_folder');
36
        if (is_string($jsonsPath) && file_exists($jsonsPath)) {
37
            exec("chown -R $user:$group $jsonsPath");
38
        }
39
    }
40
}
41