QueueSize   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 38
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 9 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\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