Profiler::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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