GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 50cef7...02ca20 )
by Rolf
01:54
created

Closure   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 31
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A _applies() 0 4 1
1
<?php
2
namespace izzum\rules;
3
4
/**
5
 * A Closure rule allows us to easily add logic to a rule by means of an
6
 * anonymous
7
 * function.
8
 *
9
 * This provides flexibility to clients that do not want to subclass a Rule but
10
 * still want to work with the rules library.
11
 *
12
 * $rule = new Closure(function ($a, $b) { return $a === $b; }), array(1,2));
13
 * $rule->applies();//returns false: 1 is not equal to 2
14
 */
15
class Closure extends Rule {
16
    /**
17
     *
18
     * @var \Closure
19
     */
20
    private $closure;
21
    
22
    /**
23
     * an array of arguments to pass as parameters to the closure
24
     * 
25
     * @var mixed[]
26
     */
27
    private $arguments;
28
29
    /**
30
     *
31
     * @param Closure $closure            
32
     * @param mixed[] $arguments
33
     *            an optional array of arguments to pass to the closure
34
     */
35 2
    public function __construct(\Closure $closure, $arguments = array())
36
    {
37 2
        $this->closure = $closure;
38 2
        $this->arguments = $arguments;
39 2
    }
40
41 2
    protected function _applies()
42
    {
43 2
        return (boolean) call_user_func_array($this->closure, $this->arguments);
44
    }
45
}