<?php

namespace Database\Factories;

use App\Models\Project;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\NonFunctionalRequirement>
 */
class NonFunctionalRequirementFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $nfrTypes = [
            ['name' => 'Reliability', 'description' => 'System reliability and uptime requirements'],
            ['name' => 'Performance', 'description' => 'System performance and response time requirements'],
            ['name' => 'Security', 'description' => 'Security and data protection requirements'],
            ['name' => 'Scalability', 'description' => 'System scalability and growth requirements'],
            ['name' => 'Usability', 'description' => 'User experience and usability requirements'],
        ];

        $nfr = $this->faker->randomElement($nfrTypes);

        return [
            'project_id' => Project::factory(),
            'name' => $nfr['name'],
            'description' => $nfr['description'],
            'weight' => 0.00, // Default 0.00, will be calculated later
        ];
    }

    public function withType(string $type, string $description): static
    {
        return $this->state(fn (array $attributes) => [
            'name' => $type,
            'description' => $description,
        ]);
    }
}
