circusdei
circusdei

Reputation: 1967

Dynamic Enumeration in PHP. Possible? Sensible?

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?

Upvotes: 3

Views: 810

Answers (1)

Paul Sonier
Paul Sonier

Reputation: 39510

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.

Upvotes: 4

Related Questions