Lines 100.00% 4 / 4
Methods 100.00% 3 / 3
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 __construct 100.00% 2 / 2 100.00% 1 / 1 2
 empty 100.00% 1 / 1 100.00% 1 / 1 1
 full 100.00% 1 / 1 100.00% 1 / 1 1
12final readonly class Gauge
13{
14    /**
15     * @param T $current
16     * @param T $maximum
17     *
18     * @throws InvalidArgumentException
19     */
20    public function __construct(
21        public NonNegativeInteger $current,
22        public NonNegativeInteger $maximum,
23    ) {
24        if ($current->value > $maximum->value) {
25            throw new InvalidArgumentException("Gauge current {$current} is above maximum {$maximum}.");
26        }
27    }
28
29    public function empty(): bool
30    {
31        return $this->current->value === 0;
32    }
33
34    public function full(): bool
35    {
36        return $this->current->value === $this->maximum->value;
37    }
38}