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

PackageResource::getInstallMessage()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\Console\PackageResources;
4
5
abstract class PackageResource
6
{
7
    /**
8
     * The package resource description. A litle summary of what this
9
     * resource contains.
10
     *
11
     * @var string
12
     */
13
    public $description;
14
15
    /**
16
     * The resource source. Usually the source will be a set of paths to files
17
     * and/or folders.
18
     *
19
     * @var mixed
20
     */
21
    protected $source;
22
23
    /**
24
     * The resource target. The destination of the resource, usually a root
25
     * folder or file.
26
     *
27
     * @var mixed
28
     */
29
    public $target;
30
31
    /**
32
     * Whether this resource is required for the package in order to work fine.
33
     *
34
     * @var bool
35
     */
36
    public $required;
37
38
    /**
39
     * The set of installation messages for this resource. Usually, the array
40
     * should contains keys for 'install', 'overwrite' and 'success' messages.
41
     *
42
     * @var array
43
     */
44
    protected $messages;
45
46
    /**
47
     * Install or export the resource.
48
     *
49
     * @return void
50
     */
51
    abstract public function install();
52
53
    /**
54
     * Uninstall or remove the resource.
55
     *
56
     * @return void
57
     */
58
    abstract public function uninstall();
59
60
    /**
61
     * Check if the resource already exists on the target destination.
62
     *
63
     * @return bool
64
     */
65
    abstract public function exists();
66
67
    /**
68
     * Check if the resource is correctly installed.
69
     *
70
     * @return bool
71
     */
72
    abstract public function installed();
73
74
    /**
75
     * Get an installation message.
76
     *
77
     * @param string $key The message keyword
78
     * @return string
79
     */
80 15
    public function getInstallMessage($key)
81
    {
82 15
        if (! isset($this->messages[$key])) {
83 1
            return '';
84
        }
85
86 15
        return $this->messages[$key];
87
    }
88
}
89