Open heyrocker opened 10 years ago
It's a little more work, but I would prefer that individual methods returns specific objects (e.g. an IFPA\Player) or a collection object (that implements ArrayAccess). These classes would then implement a to_json
method on a base class.
Is there really a lot of benefit to that? I'm not sure there is. These objects are pretty simple.
Another idea I had was to just add a 'json' property to the returned objects and stash it in there.
It might not. I personally prefer to work with separate classes/objects as opposed to one class with many methods that returns very different content (player info, calendar info, tournament info etc). I still haven't had time to look at the API in detail, but I guess it might be small enough that you can just keep things as one big class.
I was wondering if it is useful to add a flag to the constructor that would allow you to return the raw JSON rather than the decoded object. This could be useful if you're doing some caching in your app, you wouldn't need to re-encode the object back to JSON to cache it.