Backup #1908

ID1908
Dateipfad/var/www/dev.campus.systemische-tools.de/src/Domain/ValueObject/Confidence.php
Version2
Typ modified
Größe1.3 KB
Hash4a5d062cc1dbf2c7076b1148489674f8a6de17a39dca472ebab1d4b1fe6790ff
Datum2025-12-28 01:07:07
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

declare(strict_types=1);

namespace Domain\ValueObject;

// @responsibility: Konfidenzwert (0.0-1.0) für Taxonomie-Mappings

use Domain\Constants;

final class Confidence
{
    private float $value;

    public function __construct(float $value)
    {
        if ($value < 0.0 || $value > 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);
    }
}

Vollständig herunterladen

Aktionen

Herunterladen

Andere Versionen dieser Datei

ID Version Typ Größe Datum
1908 2 modified 1.3 KB 2025-12-28 01:07
1905 1 modified 1.3 KB 2025-12-28 01:06

← Zurück zur Übersicht