QueueWaitingTime   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A name() 0 4 1
A run() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JildertMiedema\SystemMonitor\Measurements;
6
7
use Illuminate\Contracts\Queue\Queue;
8
use JildertMiedema\SystemMonitor\Measurements\Queue\WaitingTimeJob;
9
use JildertMiedema\SystemMonitor\System\MeasurementStore;
10
11
final class QueueWaitingTime implements Measurement
12
{
13
    /**
14
     * @var Queue
15
     */
16
    private $queue;
17
18
    public function __construct(Queue $queue)
19
    {
20
        $this->queue = $queue;
21
    }
22
23
    /**
24
     * The name of the.
25
     *
26
     * @return string
27
     */
28
    public function name(): string
29
    {
30
        return 'queue.waiting-time';
31
    }
32
33
    /**
34
     * Runs the measurement.
35
     *
36
     * @param MeasurementStore $store
37
     * @param array            $data
38
     */
39
    public function run(MeasurementStore $store, array $data)
40
    {
41
        $queue = array_get($data, 'queue');
42
        $key = array_get($data, 'key');
43
44
        $timerStart = microtime(true);
45
46
        $job = new WaitingTimeJob($timerStart, $key);
47
48
        $this->queue->pushOn($queue, $job);
49
    }
50
}
51