Lines
100.00%
5 / 5
Functions and Methods
100.00%
5 / 5
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| MetricLabels | 100.00% | 5 / 5 | 100.00% | 5 / 5 | 5 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| none | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| fromLabel | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| withLabel | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| listValuesByName | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Metrics\Exposition; | |
| 6 | ||
| 7 | final readonly class MetricLabels | |
| 8 | { | |
| 9 | /** @param array<non-empty-string, string> $valuesByName */ | |
| 10 | private function __construct(private array $valuesByName) {} | |
| 11 | ||
| 12 | public static function none(): self | |
| 13 | { | |
| 14 | return new self([]); | |
| 15 | } | |
| 16 | ||
| 17 | /** @param non-empty-string $name */ | |
| 18 | public static function fromLabel(string $name, string $value): self | |
| 19 | { | |
| 20 | return new self([$name => $value]); | |
| 21 | } | |
| 22 | ||
| 23 | /** @param non-empty-string $name */ | |
| 24 | public function withLabel(string $name, string $value): self | |
| 25 | { | |
| 26 | return new self([...$this->valuesByName, $name => $value]); | |
| 27 | } | |
| 28 | ||
| 29 | /** @return array<non-empty-string, string> */ | |
| 30 | public function listValuesByName(): array | |
| 31 | { | |
| 32 | return $this->valuesByName; | |
| 33 | } | |
| 34 | } |