Completed
Pull Request — master (#13)
by
unknown
01:06
created

Except::empty()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
namespace Rarst\wps;
3
4
use InvalidArgumentException;
5
6
class Except {
7
    public $pluginsDirectories;
8
    public $themesDirectories;
9
10
    /**
11
     * Creates Object of Watch Class
12
     *
13
     * @param array $pluginsDirectories Names of plugin folders to watch for
14
     *                                  Notices & Warnings
15
     * @param array $themesDirectories Names of theme folders to watch for
16
     *                                 Notices and Warnings
17
     */
18
    public function __construct($pluginsDirectories = [], $themesDirectories = [])
19
    {
20
        if(!is_array($pluginsDirectories)) {
21
            throw new InvalidArgumentException('$pluginsDirectories should be an array');
22
        }
23
24
        if(!is_array($themesDirectories)) {
25
            throw new InvalidArgumentException('$themesDirectories should be an array');
26
        }
27
28
        $this->pluginsDirectories = $pluginsDirectories;
29
        $this->themesDirectories = $themesDirectories;
30
    }
31
32
    /**
33
     * Constructor 
34
     */
35
    public static function pluginsDirectories($plugins) {
0 ignored issues
show
Unused Code introduced by
The parameter $plugins is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
        $plugins = func_get_args();
37
        
38
        if(empty($plugins)) {
39
            throw new InvalidArgumentException('Pass plugins folder names to watch for Notices & Warnings');
40
        }
41
42
        return new self($plugins, []);
43
    }
44
45
    /**
46
     * Constructor
47
     */
48
    public static function themesDirectories() {
49
        $themes = func_get_args();
50
        
51
        if(empty($themes)) {
52
            throw new InvalidArgumentException('Pass themes folder names to watch for Notices & Warnings');
53
        }
54
        return new self([], $themes);
55
    }
56
57
    public function empty() {
58
        return empty($this->pluginsDirectories) && empty($this->themesDirectories);
59
    }
60
61
    public function emptyPlugins() {
62
        return empty($this->pluginsDirectories);
63
    }
64
65
    public function emptyThemes() {
66
        return empty($this->themesDirectories);
67
    }
68
}