Passed
Push — develop ( cefedc...7e0ea6 )
by Stan
07:15
created

Exporter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 30
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0
eloc 9
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sampled() 0 7 1
A __construct() 0 3 1
1
<?php
2
3
namespace Krenor\Prometheus\Contracts;
4
5
use Krenor\Prometheus\Sample;
6
use Tightenco\Collect\Support\Collection;
7
use Krenor\Prometheus\MetricFamilySamples;
8
use Krenor\Prometheus\Storage\Concerns\StoresMetrics;
9
10
abstract class Exporter
11
{
12
    use StoresMetrics;
13
14
    protected array $data;
15
16
    /**
17
     * Exporter constructor.
18
     *
19
     * @param array $data
20
     */
21 37
    public function __construct(array $data)
22
    {
23 37
        $this->data = $data;
24 37
    }
25
26
    /**
27
     * @param Metric $metric
28
     * @param float $value
29
     * @param array $labels
30
     *
31
     * @return MetricFamilySamples
32
     */
33 37
    protected function sampled(Metric $metric, float $value, array $labels = []): MetricFamilySamples
34
    {
35 37
        return new MetricFamilySamples($metric, new Collection([
36 37
            new Sample(
37 37
                $metric->key(),
38
                $value,
39 37
                $this->labeled($metric, $labels)->get('labels')
0 ignored issues
show
Bug introduced by
It seems like $this->labeled($metric, $labels)->get('labels') can also be of type null; however, parameter $labels of Krenor\Prometheus\Sample::__construct() does only seem to accept Tightenco\Collect\Support\Collection, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

39
                /** @scrutinizer ignore-type */ $this->labeled($metric, $labels)->get('labels')
Loading history...
40
            ),
41
        ]));
42
    }
43
}
44