WaitingTimeJob   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 9 1
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