1.0) { throw new \InvalidArgumentException( sprintf('Confidence must be between 0.0 and 1.0, got %f', $value) ); } $this->value = $value; } public static function fromFloat(float $value): self { return new self($value); } public static function high(): self { return new self(0.9); } public static function medium(): self { return new self(0.7); } public static function low(): self { return new self(0.5); } public function value(): float { return $this->value; } public function isHigh(): bool { return $this->value >= 0.8; } public function isMedium(): bool { return $this->value >= 0.5 && $this->value < 0.8; } public function isLow(): bool { return $this->value < 0.5; } public function asPercentage(): int { return (int) round($this->value * 100); } }