Completed
Pull Request — master (#4)
by Michael
04:15
created

CallableToDelegateAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A process() 0 6 1
1
<?php
2
namespace Equip\Dispatch;
3
4
use Interop\Http\Middleware\DelegateInterface;
5
use Psr\Http\Message\RequestInterface;
6
use Psr\Http\Message\ResponseInterface;
7
8
class CallableToDelegateAdapter implements DelegateInterface
9
{
10
    /**
11
     * @var callable
12
     */
13
    private $adaptee;
14
15
    /**
16
     * @param callable $adaptee
17
     */
18 2
    public function __construct(callable $adaptee)
19
    {
20 2
        $this->adaptee = $adaptee;
21 2
    }
22
23
    /**
24
     * Process the request using a callable.
25
     *
26
     * @param RequestInterface $request
27
     *
28
     * @return ResponseInterface
29
     */
30 2
    public function process(RequestInterface $request)
31
    {
32 2
        $adaptee = $this->adaptee;
33
34 2
        return $adaptee($request);
35
    }
36
}
37