Passed
Push — master ( 84bb5a...db2eab )
by Dayle
46s
created

ClosureMatcher::match()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 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