Completed
Push — master ( 3b9ac7...e8290d )
by Dmitry
03:08
created

DebuggerMiddleware::flush()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tarantool\Mapper\Middleware;
6
7
use Exception;
8
use LogicException;
9
use Tarantool\Client\Handler\Handler;
10
use Tarantool\Client\Request\Authenticate;
11
use Tarantool\Client\Request\Request;
12
use Tarantool\Client\Response;
13
use Tarantool\Client\Middleware\Middleware;
14
15
class DebuggerMiddleware implements Middleware
16
{
17
    private $log = [];
18
19
    public function process(Request $request, Handler $handler) : Response
20
    {
21
        $start = microtime(true);
22
23
        $response = $handler->handle($request);
24
25
        $this->log[] = [
26
            'request' => $request,
27
            'response' => $response,
28
            'timing' => microtime(true) - $start,
29
        ];
30
31
        return $response;
32
    }
33
34
    public function flush() : self
35
    {
36
        $this->log = [];
37
        return $this;
38
    }
39
40
    public function getLog() : array
41
    {
42
        return $this->log;
43
    }
44
}