* @version : HUOSDK 8.5 */ namespace huoIdentify\identifyDriver; use huolib\constant\IdentifyConst; use huolib\status\IdentifyStatus; use think\Exception; use think\Log; class Identify { static $ins; private $identify_from = [ 'default' => IdentifyConst::DRIVER_NAME_ALIPAY, IdentifyConst::DRIVER_KEY_ALIPAY => IdentifyConst::DRIVER_NAME_ALIPAY, IdentifyConst::DRIVER_KEY_WXPAY => IdentifyConst::DRIVER_NAME_WXPAY, IdentifyConst::DRIVER_KEY_FCMGAME => IdentifyConst::DRIVER_NAME_FCMGAME, IdentifyConst::DRIVER_KEY_YIWAN => IdentifyConst::DRIVER_NAME_YIWAN, IdentifyConst::DRIVER_KEY_HUOUNION => IdentifyConst::DRIVER_NAME_HUOUNION, IdentifyConst::DRIVER_KEY_GUOPAN => IdentifyConst::DRIVER_NAME_GUOPAN, IdentifyConst::DRIVER_KEY_JUEFENG => IdentifyConst::DRIVER_NAME_JUEFENG, IdentifyConst::DRIVER_KEY_QIANXI => IdentifyConst::DRIVER_NAME_QIANXI, IdentifyConst::DRIVER_KEY_YIXIN => IdentifyConst::DRIVER_NAME_YIXIN, IdentifyConst::DRIVER_KEY_LIEBAO => IdentifyConst::DRIVER_NAME_LIEBAO, IdentifyConst::DRIVER_KEY_TIANYU => IdentifyConst::DRIVER_NAME_TIANYU, IdentifyConst::DRIVER_KEY_KUCHANG => IdentifyConst::DRIVER_NAME_KUCHANG, IdentifyConst::DRIVER_KEY_MOXING => IdentifyConst::DRIVER_NAME_MOXING, IdentifyConst::DRIVER_KEY_HUANJUYOU => IdentifyConst::DRIVER_NAME_HUANJUYOU, IdentifyConst::DRIVER_KEY_HAIQUYOU => IdentifyConst::DRIVER_NAME_HAIQUYOU, ]; public static function ins() { if (self::$ins == null) { self::$ins = new self(); } return self::$ins; } /** * @param string $identify_from * @param array $config * * @return mixed * @throws Exception */ public function get($identify_from = '', $config = []) { if (empty($identify_from)) { return $this->register('default'); } $_pay_obj = $this->register($identify_from, $config); if (!isset($_pay_obj)) { Log::write( "func=".__FUNCTION__."&class=".__CLASS__."&errmsg=registerError&identify_from=".$identify_from .'objName='.$this->identify_from[$identify_from], 'info' ); $_code = IdentifyStatus::IDENTIFY_FROM_INCORRECT; throw new Exception(IdentifyStatus::getMsg($_code), $_code); } return $_pay_obj; } /** * @param string $identify_from * @param array $config * * @return Driver */ protected function register($identify_from = '', $config = []) { $identify_from = strtolower($identify_from); $_class = '\\huoIdentify\\identifyDriver\\driver\\'.$this->identify_from[$identify_from]; return new $_class($config); } }