| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Prometheus; |
| 6 |
|
| 7 |
class MetricFamilySamples |
| 8 |
{ |
| 9 |
/** |
| 10 |
* @var mixed |
| 11 |
*/ |
| 12 |
private $name; |
| 13 |
|
| 14 |
/** |
| 15 |
* @var string |
| 16 |
*/ |
| 17 |
private $type; |
| 18 |
|
| 19 |
/** |
| 20 |
* @var string |
| 21 |
*/ |
| 22 |
private $help; |
| 23 |
|
| 24 |
/** |
| 25 |
* @var string[] |
| 26 |
*/ |
| 27 |
private $labelNames; |
| 28 |
|
| 29 |
/** |
| 30 |
* @var Sample[] |
| 31 |
*/ |
| 32 |
private $samples = []; |
| 33 |
|
| 34 |
/** |
| 35 |
* @param mixed[] $data |
| 36 |
*/ |
| 37 |
public function __construct(array $data) |
| 38 |
{ |
| 39 |
$this->name = $data['name']; |
| 40 |
$this->type = $data['type']; |
| 41 |
$this->help = $data['help']; |
| 42 |
$this->labelNames = $data['labelNames']; |
| 43 |
foreach ($data['samples'] as $sampleData) { |
| 44 |
$this->samples[] = new Sample($sampleData); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* @return string |
| 50 |
*/ |
| 51 |
public function getName(): string |
| 52 |
{ |
| 53 |
return $this->name; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* @return string |
| 58 |
*/ |
| 59 |
public function getType(): string |
| 60 |
{ |
| 61 |
return $this->type; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* @return string |
| 66 |
*/ |
| 67 |
public function getHelp(): string |
| 68 |
{ |
| 69 |
return $this->help; |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* @return Sample[] |
| 74 |
*/ |
| 75 |
public function getSamples(): array |
| 76 |
{ |
| 77 |
return $this->samples; |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* @return string[] |
| 82 |
*/ |
| 83 |
public function getLabelNames(): array |
| 84 |
{ |
| 85 |
return $this->labelNames; |
| 86 |
} |
| 87 |
|
| 88 |
/** |
| 89 |
* @return bool |
| 90 |
*/ |
| 91 |
public function hasLabelNames(): bool |
| 92 |
{ |
| 93 |
return $this->labelNames !== []; |
| 94 |
} |
| 95 |
} |
| 96 |
|