<?php
/**
 *
 * @author jhx
 * @date 2021/9/28 15:45
 */

namespace app\server;


use GuzzleHttp\Client;

class GuzzleServer
{
    public function __construct()
    {
    }

    /**
     * singleton
     */
    protected static $instanceClient = null;

    /**
     * destruct.
     */
    public function __destruct()
    {
        static::$instanceClient = null;
    }

    /**
     * 获取单例
     * @param array $config 配置参数
     */
    public static function getClient($config = []): Client
    {
        if (!(static::$instanceClient instanceof Client)) {
            static::$instanceClient = new Client($config);
        }
        return static::$instanceClient;
    }
}