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

Exporter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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