-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
增加 OneBotBuilder #45
增加 OneBotBuilder #45
Conversation
对于开发者引入此库进行编写时,我觉得倒是 OneBotBuilder 也不是不可,但是 OneBotBuilder 后返回的对象却是 OneBot 总感觉哪里不太对劲,OneBot 好像被架空了(因为目前的写法看起来是不允许使用构造函数创建 OneBot)。 按理说 OneBot 对象的作用就是 OneBot 实现的核心类,而如果使用 OneBotBuilder,应该感觉类似于做 HttpFactory 的 |
OneBot 依然是核心类呀,使用 OneBotBuilder 构建 OneBot 和 new OneBot 本质上没有区别,只是中间多了一层转换,用于解析 logger 和 driver,OneBotBuilder::buildFromConfig 和 new OneBot($config) 的作用是完全一样的。
目前 OneBot 是可以直接使用的呀,如果不喜欢 OneBotBuilder 的话可以直接 new OneBot($config),只是传入的 config 中的 logger 和 driver 必须是实例而已。 |
但 OneBot 实例的构造函数不应该是 private 呀:
|
阿这,为什么是 private 😨 |
知道了,昨晚写嗨了,发现 getInstance 有初始化的功能之后就非常自信地把new给去了。 |
还有驼峰命名是否有问题呢,OneBot 使用的都是下划线,但 Builder 中使用的是驼峰。 |
我其实是说的这里的驼峰🤔 |
自动生成的,没留意看 🤣 |
set
例子:
见 demo.php