<?php

namespace Kylin\RealnameGateway;

use Illuminate\Support\ServiceProvider;
use Kylin\RealnameGateway\Services\IdCardValidator;
use Kylin\RealnameGateway\Services\NppaGatewayService;

/**
 * 实名认证网关服务提供者
 *
 * 提供游戏防沉迷实名认证接口，包括：
 *  - NPPA 网关对接（国家新闻出版署）
 *  - 身份证号校验（IdCardValidator）
 *  - 未成年人身份识别
 */
class RealnameGatewayServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->mergeConfigFrom(__DIR__ . '/../config/kylin-realname-gateway.php', 'kylin-realname-gateway');

        $this->app->singleton(NppaGatewayService::class);
        $this->app->singleton(IdCardValidator::class);
    }

    public function boot(): void
    {
        if ($this->app->runningInConsole()) {
            $this->publishes([
                __DIR__ . '/../config/kylin-realname-gateway.php' => config_path('kylin-realname-gateway.php'),
            ], 'kylin-realname-gateway-config');
        }
    }
}
