QueueSize::run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
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\System\MeasurementStore;
9
10
final class QueueSize implements Measurement
11
{
12
    /**
13
     * @var Queue
14
     */
15
    private $queue;
16
17
    public function __construct(Queue $queue)
18
    {
19
        $this->queue = $queue;
20
    }
21
22
    /**
23
     * The name of the.
24
     *
25
     * @return string
26
     */
27
    public function name(): string
28
    {
29
        return 'queue.size';
30
    }
31
32
    /**
33
     * Runs the measurement.
34
     *
35
     * @param MeasurementStore $store
36
     * @param array            $data
37
     */
38
    public function run(MeasurementStore $store, array $data)
39
    {
40
        $queue = array_get($data, 'queue');
41
        $key = array_get($data, 'key');
42
43
        $count = $this->queue->size($queue);
44
45
        $store->storeGauge($key, $count);
46
    }
47
}
48