PHP 中的动态枚举。可能的?明智吗?
我正在构建一个 API,它将接受来自 iPhone 应用程序的各种指标。
应用程序程序员请求 API 能够处理 API 尚不了解的指标类型。我想使用枚举来列出当前类型的指标,但在将新指标推送到服务器时必须添加新指标。
以前有人见过这样做吗?我考虑过使用数据库而不是枚举,但这看起来真的很混乱。
有什么想法吗?
I am building an API which will accept a variety of metrics from an iPhone application.
The App Programmer has requested that the API be able to handle types of metrics the API does not yet know about. I would like to use an enumeration to list the current types of Metrics, but new metrics would have to be added as they are pushed to the server.
Has anyone seen this done before? I've thought about using a DB instead of an enum, but that seems really messy.
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要使用枚举。枚举主要在提前知道整个值范围时有用;这显然不是你的情况。
Don't use an enumeration. Enumerations are primarily useful for when the entire range of values is known ahead of time; this is clearly not your case.