<?php
/**
 * Copyright © Simplyin. All rights reserved.
 */
declare(strict_types=1);

namespace Simplyin\Payment\Model\Config;

use Simplyin\Payment\Environment;

/**
 * Single source of truth for the Simply.IN backend the plugin talks to.
 *
 * The environment is fixed in code ({@see Environment::APP_ENV}, set per build by the pipeline) —
 * NOT in admin/core_config_data — so merchants cannot change it. Every outbound call (request
 * signing, registration, webhooks sync) resolves its base URL from here. Injectable (not called
 * statically) so it stays mockable in unit tests.
 */
class EnvironmentConfig
{
    /**
     * Active environment, validated against the known set; falls back to production.
     *
     * @return string
     */
    public function getEnvironment(): string
    {
        $env = Environment::APP_ENV;

        return isset(Environment::BASE_URLS[$env]) ? $env : 'prod';
    }

    /**
     * Resolved backend API base URL for the active environment.
     *
     * @return string
     */
    public function getApiBaseUrl(): string
    {
        return Environment::BASE_URLS[$this->getEnvironment()];
    }
}
