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

Except::blank()   A

Complexity

Conditions 1
Paths 1

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 1
nc 1
nop 0
1
<?php
2
namespace Rarst\wps;
3
4
use InvalidArgumentException;
5
6
class Except {
7
    private $pathPatterns;
8
9
    /**
10
     * Constructor
11
     *
12
     * @param  array|string $patterns List or a single regex pattern to match
0 ignored issues
show
Documentation introduced by
There is no parameter named $patterns. Did you maybe mean $pathPatterns?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
13
     */
14
    public function __construct($pathPatterns) {
0 ignored issues
show
Unused Code introduced by
The parameter $pathPatterns 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...
15
        $pathPatterns = func_get_args();
16
17
        if(is_array($pathPatterns[0])) {
18
            $pathPatterns = $pathPatterns[0];
19
        }
20
        
21
        $this->pathPatterns = array_filter($pathPatterns);
22
    }
23
24
    /**
25
     * Constructor
26
     * 
27
     * @param array $pluginsDirectories Names of plugin folders to watch for
0 ignored issues
show
Documentation introduced by
There is no parameter named $pluginsDirectories. Did you maybe mean $plugins?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
28
     *                                  Notices & Warnings.
29
     */
30 View Code Duplication
    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...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
        $plugins = func_get_args();
32
        
33
        if(empty($plugins)) {
34
            throw new InvalidArgumentException('Pass plugins folder names to watch for Notices & Warnings');
35
        }
36
37
        $plugins = array_map(function($plugin){
38
            return '@plugins/' . preg_quote($plugin, '@') . '@';
39
        }, $plugins);
40
41
        return new self($plugins);
42
    }
43
44
    /**
45
     * Constructor
46
     * 
47
     * @param array $themesDirectories Names of theme folders to watch for
0 ignored issues
show
Bug introduced by
There is no parameter named $themesDirectories. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
48
     *                                 Notices and Warnings.
49
     */
50 View Code Duplication
    public static function themesDirectories() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
        $themes = func_get_args();
52
        
53
        if(empty($themes)) {
54
            throw new InvalidArgumentException('Pass themes folder names to watch for Notices & Warnings');
55
        }
56
57
        $themes = array_map(function($theme){
58
            return '@themes/' . preg_quote($theme, '@') . '@';
59
        }, $themes);
60
61
        return new self($themes);
62
    }
63
64
    /**
65
     * Constructor
66
     */
67
    public static function blank() {
68
        return new self([]);
69
    }
70
71
    public function empty() {
72
        return empty($this->pathPatterns);
73
    }
74
75
    public function pathPatterns() {
76
        return $this->pathPatterns;
77
    }
78
}