<?php
/**
 * Credit System Index
 *
 * Main entry point for the Credit System.
 * Handles autoloading and provides setup function.
 *
 * @package AIPT\Core\CreditSystem
 */

namespace AIPT\Core\CreditSystem;

if (!defined('ABSPATH')) {
    exit;
}

require_once __DIR__ . '/CreditCache.php';
require_once __DIR__ . '/CreditApiClient.php';
require_once __DIR__ . '/CreditManager.php';
require_once __DIR__ . '/CreditRest.php';
require_once __DIR__ . '/ParameterService.php';
require_once __DIR__ . '/CreditMigration.php';
require_once __DIR__ . '/CreditSystemBootstrap.php';

/**
 * Setup function - initializes the credit system
 *
 * @return CreditManager
 */
function setupCreditSystem(): CreditManager
{
    CreditSystemBootstrap::init();
    return CreditManager::getInstance();
}

/**
 * Get credit manager instance
 *
 * @return CreditManager
 */
function getCreditManager(): CreditManager
{
    return CreditManager::getInstance();
}

/**
 * Get parameter service instance
 *
 * @return ParameterService
 */
function getParameterService(): ParameterService
{
    static $service = null;
    if ($service === null) {
        $service = new ParameterService();
    }
    return $service;
}
