heyrocker / IfpaApi

A PHP wrapper class to simplify access the IFPA API
The Unlicense
5 stars 1 forks source link

Add ability to return raw JSON instead of decoded #1

Open heyrocker opened 10 years ago

heyrocker commented 10 years ago

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.

haugstrup commented 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.

heyrocker commented 10 years ago

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.

haugstrup commented 10 years ago

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.