Passed
Push — master ( 70acef...8b9af3 )
by Florian
07:10 queued 02:43
created

MainViewsResource   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 72
ccs 21
cts 21
cp 1
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A installed() 0 6 1
A exists() 0 3 1
A install() 0 5 1
A __construct() 0 15 1
A uninstall() 0 6 2
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\Console\PackageResources;
4
5
use JeroenNoten\LaravelAdminLte\Helpers\CommandHelper;
6
7
class MainViewsResource extends PackageResource
8
{
9
    /**
10
     * Create a new resource instance.
11
     *
12
     * @return void
13
     */
14 18
    public function __construct()
15
    {
16
        // Fill the resource data.
17
18 18
        $this->description = 'The default package main views';
19 18
        $this->source = CommandHelper::getPackagePath('resources/views');
20 18
        $this->target = CommandHelper::getViewPath('vendor/adminlte');
21 18
        $this->required = false;
22
23
        // Fill the set of installation messages.
24
25 18
        $this->messages = [
26
            'install'   => 'Install the AdminLTE main views?',
27
            'overwrite' => 'The main views already exists. Want to replace the views?',
28
            'success'   => 'Main views installed successfully.',
29
        ];
30 18
    }
31
32
    /**
33
     * Install/Export the resource.
34
     *
35
     * @return void
36
     */
37 2
    public function install()
38
    {
39
        // Install the main views.
40
41 2
        CommandHelper::copyDirectory($this->source, $this->target, true, true);
42 2
    }
43
44
    /**
45
     * Uninstall/Remove the resource.
46
     *
47
     * @return void
48
     */
49 2
    public function uninstall()
50
    {
51
        // Uninstall the package main views.
52
53 2
        if (is_dir($this->target)) {
54 2
            CommandHelper::removeDirectory($this->target);
55
        }
56 2
    }
57
58
    /**
59
     * Check if the resource already exists on the target destination.
60
     *
61
     * @return bool
62
     */
63 3
    public function exists()
64
    {
65 3
        return is_dir($this->target);
66
    }
67
68
    /**
69
     * Check if the resource is correctly installed.
70
     *
71
     * @return bool
72
     */
73 3
    public function installed()
74
    {
75 3
        return (bool) CommandHelper::compareDirectories(
76 3
            $this->source,
77 3
            $this->target,
78 3
            true
79
        );
80
    }
81
}
82