<?php

namespace App\Services\CreditScore;

class ComponentResult
{
    public function __construct(
        public readonly string $name,
        public readonly float $normalizedScore,
        public readonly bool $available = true,
        public readonly array $factors = [],
        public readonly array $positiveFactors = [],
        public readonly array $negativeFactors = [],
    ) {
    }

    public function toArray(): array
    {
        return [
            'name' => $this->name,
            'normalized_score' => round($this->normalizedScore, 2),
            'available' => $this->available,
            'factors' => $this->factors,
            'positive_factors' => $this->positiveFactors,
            'negative_factors' => $this->negativeFactors,
        ];
    }
}
