QueueWaitingTime::name()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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