ResponseBenchmarkFormatter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A format() 0 3 1
A name() 0 3 1
1
<?php
2
3
namespace San4io\RequestLogger\Logger\ContextFormatters;
4
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\HttpFoundation\Response;
7
use San4io\RequestLogger\Contracts\ContextFormatterContract;
8
use San4io\RequestLogger\Services\BenchmarkService;
9
10
class ResponseBenchmarkFormatter implements ContextFormatterContract
11
{
12
    /**
13
     * @var BenchmarkService
14
     */
15
    protected $benchmarkService;
16
17
    /**
18
     * BenchmarkFormatter constructor.
19
     * @param BenchmarkService $benchmarkService
20
     */
21
    public function __construct(BenchmarkService $benchmarkService)
22
    {
23
        $this->benchmarkService = $benchmarkService;
24
    }
25
26
    /**
27
     * @param \Illuminate\Http\Request $request
28
     * @param \Illuminate\Http\Response $response
29
     * @return string
30
     */
31
    public function format(Request $request, Response $response)
32
    {
33
        return $this->benchmarkService->result();
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function name(): string
40
    {
41
        return 'response_ms';
42
    }
43
}