1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Wechat;
- class WechatParam
- {
- private $param;
- private static $_instance = null;
- private function __construct($param)
- {
- $this->param = $param;
- }
- /**
- * 单例模式的实例
- */
- public static function instance()
- {
- if (self::$_instance == null) {
- self::$_instance = new self(
- [
- 'appid' => 'wxa3dec10df68cd87d',
- 'appsecret' => '17bff4aa5bf1ffa2c15aeb5eea0e2b32',
- ]);
- }
- return self::$_instance;
- }
- /**
- * set方法
- */
- public function set($name, $value)
- {
- $this->param[$name] = $value;
- }
- /**
- * get方法
- */
- public function get($name)
- {
- if (empty($this->param[$name])) {
- return null;
- }
- return $this->param[$name];
- }
- /**
- * 获取所有参数
- */
- public function getParam()
- {
- return $this->param;
- }
- /**
- * 合并参数
- */
- public function merge($arr)
- {
- $this->param = array_merge($this->param,$arr);
- }
- }
|