I feel silly for asking, but how do I get plan value in this object? _object is protected, so PHP telling me I cannot. I am using the PHP library for Recurly.
object(Recurly_SubscriptionList)#47 (7) {
["_etag":"Recurly_Pager":private]=> NULL
["_position":"Recurly_Pager":private]=>int(0)
["_count":"Recurly_Pager":private]=>NULL
["_objects":protected]=> array(1) {
[0]=> object(Recurly_Subscription)#50 (6) {
["_values":protected]=> array(11) {
["subscription_add_ons"]=> array(0) {}
["account"]=> object(Recurly_Stub)#54 (4) {
["objectType"]=> string(7) "account"
["_href":protected]=> string(37) "https://api.recurly.com/v2/accounts/1"
["_client":protected]=>NULL
["_links":protected]=>array(0) {}
}
["plan"]=> hello
So since I come from a Java background, I was expecting a
getVar()function. It turns out that PHP’s Magic Method__get()allows me to just access it normally IF you overload your__get()properly.So in specific to this case, for whoever that may stumble on to this, if you are using the Recurly PHP Library, you have to use
foreachto get to the objects and then just accessplannormally.For example,
Let’s say the object above was the value of the variable
$subscriptions: