<?php

declare(strict_types=1);

namespace Plugin\tnt_mcp\src\Mcp\Support;

use JTL\Catalog\Currency;
use JTL\Language\LanguageHelper;
use JTL\Shop;

/**
 * Production {@see ShopInfo}: delegates every value to JTL's own accessors — the global settings
 * for the shop name, {@see LanguageHelper::getDefaultLanguage()} for the default language, and
 * {@see Currency::getDefault()} for the default currency. No value is re-derived or cached here.
 */
final class JtlShopInfoProvider implements ShopInfo
{
    public function name(): ?string
    {
        $name = Shop::getSettings([\CONF_GLOBAL])['global']['global_shopname'] ?? null;

        return \is_string($name) && $name !== '' ? $name : null;
    }

    public function url(): ?string
    {
        $url = Shop::getURL();

        return $url !== '' ? $url : null;
    }

    public function defaultLanguageIso(): ?string
    {
        $iso = LanguageHelper::getDefaultLanguage()->getIso();

        return $iso !== '' ? $iso : null;
    }

    public function defaultCurrencyCode(): ?string
    {
        return (new Currency())->getDefault()->getCode();
    }
}
