<?php

namespace Config;

use CodeIgniter\Config\BaseService;

//choi.jh
use App\Services\Auth\GoogleService;
use App\Services\Auth\LocalService;
use App\Services\BoardService;
use App\Services\UserService;
//choi.jh

/**
 * Services Configuration file.
 *
 * Services are simply other classes/libraries that the system uses
 * to do its job. This is used by CodeIgniter to allow the core of the
 * framework to be swapped out easily without affecting the usage within
 * the rest of your application.
 *
 * This file holds any application-specific services, or service overrides
 * that you might need. An example has been included with the general
 * method format you should use for your service methods. For more examples,
 * see the core Services file at system/Config/Services.php.
 */
class Services extends BaseService
{
    /*
     * public static function example($getShared = true)
     * {
     *     if ($getShared) {
     *         return static::getSharedInstance('example');
     *     }
     *
     *     return new \CodeIgniter\Example();
     * }
     */
    //choi.jh
    public static function myauth($getShared = true): LocalService
    {
        if ($getShared) {
            return static::getSharedInstance(__FUNCTION__);
        } else {
            return new LocalService(
                new \App\Models\UserModel()
            );
        }
    }
    //로그인처리용
    public static function localauth($getShared = true): LocalService
    {
        if ($getShared) {
            return static::getSharedInstance(__FUNCTION__);
        } else {
            return new LocalService(
                new \App\Models\UserModel()
            );
        }
    }
    public static function googleauth($getShared = true): GoogleService
    {
        if ($getShared) {
            return static::getSharedInstance(__FUNCTION__);
        }
        return new GoogleService(
            new \App\Models\USerModel(),
            new \App\Libraries\MySocket\GoogleSocket\CURL()
        );
    }
    //로그인처리용
    public static function userservice($getShared = true): UserService
    {
        if ($getShared) {
            return static::getSharedInstance(__FUNCTION__);
        }
        return new UserService(
            new \App\Models\USerModel()
        );
    }

    public static function boardservice($getShared = true): BoardService
    {
        if ($getShared) {
            return static::getSharedInstance(__FUNCTION__);
        }
        return new BoardService(
            new \App\Models\BoardModel(),
        );
    }
    //choi.jh
}
