AdminLteUpdateCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 52
ccs 7
cts 7
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 15 3
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\Console;
4
5
use Illuminate\Console\Command;
6
use JeroenNoten\LaravelAdminLte\Console\PackageResources\LayoutViewsResource;
7
8
class AdminLteUpdateCommand extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'adminlte:update ';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Updates the AdminLTE distribution files and its dependencies';
23
24
    /**
25
     * A warning notification to be used when main views were previously
26
     * installed/published.
27
     *
28
     * @var string
29
     */
30
    protected $layoutViewsWarn = '<fg=yellow>Outdated layout views at %s</>
31
    <fg=cyan>
32
    We detected that the package layout views were previously published and they
33
    differs from the ones currently available. Note this package may not work
34
    correctly if you do not update those views manually in order to include the
35
    latest changes. In the particular case you have recently changed those views
36
    to include own customizations, then you can ignore this warning. Please,
37
    refer to next link for more instructions on how to update the views:
38
    https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Updating</>';
39
40
    /**
41
     * Execute the console command.
42
     *
43
     * @return void
44
     */
45 3
    public function handle()
46
    {
47 3
        $options = ['--force' => true, '--only' => ['assets']];
48
49 3
        $this->call('adminlte:install', $options);
50
51
        // When the layout views were previously published and they differs
52
        // from the package default ones, alarm the user to notify that those
53
        // views may require a manual update.
54
55 3
        $layoutViewsRes = new LayoutViewsResource();
56
57 3
        if ($layoutViewsRes->exists() && ! $layoutViewsRes->installed()) {
58 1
            $msg = sprintf($this->layoutViewsWarn, $layoutViewsRes->target);
59 1
            $this->info($msg);
60
        }
61
    }
62
}
63