Event::time()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Personnage\Tinkoff\SDK\Event;
4
5
use League\Event\AbstractEvent;
6
use Psr\Http\Message\RequestInterface;
7
8
abstract class Event extends AbstractEvent
9
{
10
    /**
11
     * @var RequestInterface
12
     */
13
    public $request;
14
15
    /**
16
     * @var float
17
     */
18
    public $startTime;
19
20
    /**
21
     * @var float
22
     */
23
    public $endTime;
24
25
    /**
26
     * Create a new instance.
27
     *
28
     * @param RequestInterface  $request   The request instance.
29
     * @param float             $startTime The timestamp of the start of the request, with microsecond precision.
30
     * @param float             $endTime   The timestamp of the end of the request, with microsecond precision.
31
     */
32
    public function __construct(RequestInterface $request, float $startTime, float $endTime)
33
    {
34
        $this->request = $request;
35
        $this->startTime = $startTime;
36
        $this->endTime = $endTime;
37
    }
38
39
    /**
40
     * Get total time.
41
     *
42
     * @return float
43
     */
44
    public function time(): float
45
    {
46
        return $this->endTime - $this->startTime;
47
    }
48
}
49