Profiler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 7 1
1
<?php
2
3
namespace GuzzleHttp\Profiling\Clockwork;
4
5
use Clockwork\Request\Timeline;
6
use GuzzleHttp\Profiling\DescriptionMaker;
7
use GuzzleHttp\Profiling\Profiler as ProfilerContract;
8
use Psr\Http\Message\RequestInterface;
9
use Psr\Http\Message\ResponseInterface;
10
11
class Profiler implements ProfilerContract
12
{
13
    use DescriptionMaker;
14
15
    /**
16
     * @var \Clockwork\Request\Timeline
17
     */
18
    private $timeline;
19
20
    /**
21
     * Public constructor.
22
     *
23
     * @param \Clockwork\Request\Timeline $timeline
24
     */
25 1
    public function __construct(Timeline $timeline)
26
    {
27 1
        $this->timeline = $timeline;
28 1
    }
29
30
    /**
31
     * @param float $start
32
     * @param float $end
33
     * @param \Psr\Http\Message\RequestInterface $request
34
     * @param \Psr\Http\Message\ResponseInterface $response
35
     */
36 1
    public function add(float $start, float $end, RequestInterface $request, ResponseInterface $response = null): void
37
    {
38 1
        $description = $this->describe($request, $response);
39 1
        $name = spl_object_hash($request);
40
41 1
        $this->timeline->addEvent($name, $description, $start, $end);
42 1
    }
43
}
44