<?php

namespace Config;

use CodeIgniter\Config\BaseConfig;

/**
 * API-Football (api-sports.io) integration.
 *
 * Set API_FOOTBALL_KEY in your server .env file.
 */
class ApiFootball extends BaseConfig
{
    public string $baseUrl = 'https://v3.football.api-sports.io';

    public string $timezone = 'Africa/Nairobi';

    public int $defaultSeason = 2025;

    /** Milliseconds to sleep between API calls during bulk sync. */
    public int $requestDelayMs = 200;

    /** Team cache TTL (seconds) — 7 days. */
    public int $teamsCacheTtl = 604800;

    /** Fixture cache TTL (seconds) — 6 hours. */
    public int $fixturesCacheTtl = 21600;

    public function getApiKey(): string
    {
        $key = getenv('API_FOOTBALL_KEY');

        return $key !== false ? (string) $key : '';
    }
}
