Completed
Push — master ( 75531c...b3ba0a )
by Joel
8s
created

CallbackRequestMatcher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A matches() 0 4 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