WaitingTimeJob::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JildertMiedema\SystemMonitor\Measurements\Queue;
6
7
use Illuminate\Contracts\Container\Container;
8
use Illuminate\Contracts\Queue\ShouldQueue;
9
10
final class WaitingTimeJob implements ShouldQueue
11
{
12
    /**
13
     * @var float
14
     */
15
    private $startTime;
16
17
    /**
18
     * @var string
19
     */
20
    private $key;
21
22
    /**
23
     * @param $startTime
24
     * @param string $key
25
     */
26
    public function __construct($startTime, string $key)
27
    {
28
        $this->startTime = $startTime;
29
        $this->key = $key;
30
    }
31
32
    public function handle(Container $container)
33
    {
34
        $store = $container->make('measurement.store');
35
36
        $timerEnd = microtime(true);
37
        $time = round(($timerEnd - $this->startTime) * 1000, 4);
38
39
        $store->storeTimer($this->key, $time.'|ms');
40
    }
41
}
42