paquettg / leaguewrap

League of Legend API wrapper
MIT License
67 stars 28 forks source link

Object Oriented #48

Open ctsstc opened 9 years ago

ctsstc commented 9 years ago

Why are there so many calls that require id's for instance a summoner id:

$api->stats()->ranked($summoner->id);

Rather than be like:

$summoner->stats->ranked();

I imagine this saves api calls? But if you have a populated summoner instance then you'll have the summoner Id available to that instance. I imagine that we would also then need to have static methods / the current method so that when you already had id's on hand via DB or etc that you could still call them. Maybe there could be a way to populate instances too with an array pulled from the DB/ORM?

dnlbauer commented 9 years ago

You can also do $api->stats()->ranked($summoner); or $api->stats()->ranked( [$summoner1, $summoner2, $summoner3] );

There is no need to extract the Id on your own.

ctsstc commented 9 years ago

thanks that should help :)

it'd still be nice to see some alias wrappers for having something like:

$summoner->stats->ranked();
paquettg commented 9 years ago

I agree with you but the problem in implementing this feature is two folds.

First, the summoner DTO that you are using does not know about the API, it's only a data transfer object and, as such, only contains information that we got from the api.

Second, this would add a lot of extra methods, or attributes, to the summoner dto which do not really belong.

How would you propose solving both of these design issues?