PublishCommand::handle()   A
last analyzed

Complexity

Conditions 5
Paths 7

Size

Total Lines 34
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 34
rs 9.2568
cc 5
nc 7
nop 0
1
<?php
2
3
namespace Itstructure\GridView\Commands;
4
5
use Illuminate\Console\Command;
6
use Itstructure\GridView\GridViewServiceProvider;
7
8
/**
9
 * Class PublishCommand
10
 *
11
 * @package Itstructure\GridView\Commands
12
 *
13
 * @author Andrey Girnik <[email protected]>
14
 */
15
class PublishCommand extends Command
16
{
17
    /**
18
     * The name and signature of the console command.
19
     * @var string
20
     */
21
    protected $signature = 'grid_view:publish '.
22
    '{--force : Overwrite existing files by default.}'.
23
    '{--only= : Publish only specific part. Available parts: views, lang.}';
24
25
    /**
26
     * The console command description.
27
     * @var string
28
     */
29
    protected $description = 'Publish GridView package parts.';
30
31
    /**
32
     * Execute the console command.
33
     * @return void
34
     */
35
    public function handle()
36
    {
37
        $this->info('Starting publication process of GridView package parts...');
38
39
        $callArguments = ['--provider' => GridViewServiceProvider::class];
40
41
        if ($this->option('only')) {
42
            switch ($this->option('only')) {
43
                case 'views':
44
                    $this->info('Publish just a part: views.');
45
                    $callArguments['--tag'] = 'views';
46
                    break;
47
48
                case 'lang':
49
                    $this->info('Publish just a part: lang.');
50
                    $callArguments['--tag'] = 'lang';
51
                    break;
52
53
                default:
54
                    $this->error('Invalid "only" argument value!');
55
                    return;
56
                    break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
57
            }
58
59
        } else {
60
            $this->info('Publish all parts: views, lang.');
61
        }
62
63
        if ($this->option('force')) {
64
            $this->warn('Force publishing.');
65
            $callArguments['--force'] = true;
66
        }
67
68
        $this->call('vendor:publish', $callArguments);
69
    }
70
}
71