Passed
Push — develop ( 500084...288399 )
by Stan
09:28
created

Exporter::sampled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 7
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
    /**
15
     * @var array
16
     */
17
    protected $data;
18
19
    /**
20
     * Exporter constructor.
21
     *
22
     * @param array $data
23
     */
24
    public function __construct(array $data)
25
    {
26
        $this->data = $data;
27
    }
28
29
    /**
30
     * @param Metric $metric
31
     * @param float $value
32
     * @param array $labels
33
     *
34
     * @return MetricFamilySamples
35
     */
36
    protected function sampled(Metric $metric, float $value, array $labels = []): MetricFamilySamples
37
    {
38
        return new MetricFamilySamples($metric, new Collection([
39
            new Sample(
40
                $metric->key(),
41
                $value,
42
                $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

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