Skip to content

Commit 7aea656

Browse files
authored
Handle empty values (#2)
* Handle empty values * Fix linting
1 parent 23e6389 commit 7aea656

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Metric.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class Metric {
3333
*
3434
* @var \PNX\Prometheus\LabelledValue[]
3535
*/
36-
protected $labelledValues;
36+
protected $labelledValues = [];
3737

3838
/**
3939
* Metric constructor.

tests/Unit/GaugeTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,15 @@ public function testGauge() {
3535

3636
}
3737

38+
/**
39+
* Ensure a gauge with no values is valid.
40+
*
41+
* @covers ::__construct
42+
* @covers ::getLabelledValues
43+
*/
44+
public function testGaugeNoValues() {
45+
$gauge = new Gauge("foo", "bar", "A test gauge");
46+
$this->assertEmpty($gauge->getLabelledValues());
47+
}
48+
3849
}

0 commit comments

Comments
 (0)