Completed
Push — master ( b3ba0a...a3b45d )
by Joel
18:09
created

CallbackRequestMatcher::matches()   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 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Http\Message\RequestMatcher;
4
5
use Http\Message\RequestMatcher;
6
use Psr\Http\Message\RequestInterface;
7
8
/**
9
 * Match a request with a callback.
10
 *
11
 * @author Márk Sági-Kazár <[email protected]>
12
 */
13
final class CallbackRequestMatcher implements RequestMatcher
14
{
15
    /**
16
     * @var callable
17
     */
18
    private $callback;
19
20
    /**
21
     * @param callable $callback
22
     */
23 4
    public function __construct(callable $callback)
24
    {
25 4
        $this->callback = $callback;
26 4
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 2
    public function matches(RequestInterface $request)
32
    {
33 2
        return (bool) call_user_func($this->callback, $request);
34
    }
35
}
36