Lines 100.00% 5 / 5
Methods 100.00% 5 / 5
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 __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
7final 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}