Completed
Pull Request — master (#17)
by
unknown
03:54
created

ClosureMatcher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A match() 0 4 1
1
<?php
2
3
namespace Scientist\Matchers;
4
5
/**
6
 * Class ClosureMatcher
7
 *
8
 * @package \Scientist\Matchers
9
 */
10
class ClosureMatcher implements Matcher
11
{
12
    /**
13
     * A closure which attempts to match the results.
14
     * @var \Closure
15
     */
16
    protected $closure;
17
18
    /**
19
     * Create a new matcher instance based on a closure.
20
     * @param \Closure $closure The closure to use
21
     */
22 3
    public function __construct(\Closure $closure)
23
    {
24 3
        $this->closure = $closure;
25 3
    }
26
27
    /**
28
     * @inheritDoc
29
     */
30 2
    public function match($control, $trial)
31
    {
32 2
        return call_user_func($this->closure, $control, $trial);
33
    }
34
}
35