Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
MetricValue
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
5
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 of
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 unavailable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isAvailable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 value
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4/**
5 * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
6 * SPDX-License-Identifier: AGPL-3.0-or-later
7 */
8
9namespace OCA\Libresign\Service\UsageStatistics\Model;
10
11/**
12 * A collector answer for one metric: either a value or an explicit statement
13 * that the metric cannot be known for the requested period.
14 */
15final class MetricValue {
16    private function __construct(
17        private readonly bool $available,
18        private readonly int|bool|string|null $value,
19    ) {
20    }
21
22    public static function of(int|bool|string $value): self {
23        return new self(true, $value);
24    }
25
26    public static function unavailable(): self {
27        return new self(false, null);
28    }
29
30    public function isAvailable(): bool {
31        return $this->available;
32    }
33
34    public function value(): int|bool|string|null {
35        return $this->value;
36    }
37}