<?php

namespace Ycpay;


/**
 * @method static \Ycpay\Ali Ali()
 * @method static \Ycpay\Kuaishou Kuaishou()
 * @method static \Ycpay\Byte Byte()
 * @method static \Ycpay\Baidu Baidu()
 * @method static \Ycpay\Weixin Weixin()
 */
class Factory
{
    public static $instance = [
        'Baidu' => '\Ycpay\Baidu',
        'Byte' => '\Ycpay\Byte',
        'Weixin' => '\Ycpay\Weixin',
        'Kuaishou' => '\Ycpay\Kuaishou',
        'Ali' => '\Ycpay\Ali',
    ];

    public static function getInstance($ClassName)
    {
        static $class;
        if (isset($class[$ClassName])) {
            return $class[$ClassName];
        }

        return $class[$ClassName] = new self::$instance[$ClassName]();
    }

    public static function __callStatic($method, $args)
    {
        return self::getInstance($method, $args);
    }
}
