<?php
declare(strict_types=1);
namespace App\Platform\Health;

final class HealthScoreCalculator
{
    /** @param list<HealthResult> $results */
    public function calculate(array $results): int
    {
        $weight = 0; $total = 0;
        foreach ($results as $result) {
            $w = max(1, $result->weight);
            $weight += $w;
            $total += max(0, min(100, $result->score)) * $w;
        }
        return $weight > 0 ? (int)round($total / $weight) : 0;
    }
}
