vendredi 27 mars 2015

"chaining" a class to a main class

I couldn't think of the way to describer what I want to do, but I've seen several libraries and frameworks do it and I'm trying to figure it out for something I'm working on.


I'm working on an API client that has multiple classes. I have a main class that will contain all the OAuth stuff. I'd like the person using my API Client to be able to do something like so:



$api = baseAPI();

$user = $api->user->getUserProfile('user');

echo $user->Nickname;


user would be a class that has several methods. One could see an Admin object being accessible and a login object.


I hope I delivered my question well enough that someone understands what I'm trying to accomplish. I could try to explain it better if I did not.


Much appreciation.


Aucun commentaire:

Enregistrer un commentaire