<?php

declare(strict_types=1);

namespace App\Domain\Category;

use App\Domain\Reputation\DecayFunction;

/**
 * Abuse category. Owns the decay function and parameter that scoring uses
 * to age reports in this category — see `Decay::value()`.
 */
final class Category
{
    public function __construct(
        public readonly int $id,
        public readonly string $slug,
        public readonly string $name,
        public readonly ?string $description,
        public readonly DecayFunction $decayFunction,
        public readonly float $decayParam,
        public readonly bool $isActive,
    ) {
    }

    /**
     * @return array<string, mixed>
     */
    public function toArray(): array
    {
        return [
            'id' => $this->id,
            'slug' => $this->slug,
            'name' => $this->name,
            'description' => $this->description,
            'decay_function' => $this->decayFunction->value,
            'decay_param' => $this->decayParam,
            'is_active' => $this->isActive,
        ];
    }
}
