<?php

declare(strict_types=1);

namespace Database\Factories;

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

/** @extends Factory<Currency> */
class CurrencyFactory extends Factory
{
    protected $model = Currency::class;

    /** @return array<string, mixed> */
    public function definition(): array
    {
        return [
            'code' => strtoupper($this->faker->unique()->lexify('???')),
            'symbol' => $this->faker->randomElement(['$', '€', '£', '¥', '₹']),
            'name' => $this->faker->words(2, true),
            'decimal_places' => 2,
            'exchange_rate' => $this->faker->randomFloat(6, 0.5, 2.0),
            'is_base' => false,
            'is_enabled' => true,
            'last_synced_at' => null,
        ];
    }

    public function base(): static
    {
        return $this->state(fn (): array => [
            'code' => 'USD',
            'symbol' => '$',
            'name' => 'US Dollar',
            'exchange_rate' => 1.000000,
            'is_base' => true,
        ]);
    }

    public function disabled(): static
    {
        return $this->state(fn (): array => [
            'is_enabled' => false,
        ]);
    }
}
