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

Except   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

Changes 0
Metric Value
wmc 12
lcom 2
cbo 0
dl 0
loc 70
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 3
A pluginsDirectories() 0 9 2
A themesDirectories() 0 8 2
A blank() 0 3 1
A empty() 0 3 2
A emptyPlugins() 0 3 1
A emptyThemes() 0 3 1
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
    /**
58
     * Constructor
59
     */
60
    public static function blank() {
61
        return new self([], []);
62
    }
63
64
    public function empty() {
65
        return empty($this->pluginsDirectories) && empty($this->themesDirectories);
66
    }
67
68
    public function emptyPlugins() {
69
        return empty($this->pluginsDirectories);
70
    }
71
72
    public function emptyThemes() {
73
        return empty($this->themesDirectories);
74
    }
75
}