I am looking for a way to find out what is the next method in PHP OOP chain.
So if I am calling $obj->a()->b() or $obj->a->b
I want that a()/a
will know that the next chain parameter/method is b/b()
.
I had played with __get and __call but with no results.
do you have any idea for that?
I am having a lot of libraries that extend the same parent (db models).
currently I am using $db->modelA->getX()
I wish to have the option to call $db->cache->modelA->getX()
and the cache method will call the next methods in the chain, get the result and save it to cache, and next time it will get it from cache immediately.