omise / omise-php

Omise PHP library
https://docs.opn.ooo
MIT License
67 stars 41 forks source link

Provide the public access to the OmiseObject::$_values array at the whole with a method like getValues() #53

Closed dmitrii-fediuk closed 1 year ago

dmitrii-fediuk commented 7 years ago

There is a public offsetGet() method, but it returns only a particular element of the _values array, and there is no way to get the _values array at the whole.

https://github.com/omise/omise-php/blob/v2.6.0/lib/omise/res/obj/OmiseObject.php#L5-L6

guzzilar commented 7 years ago

Hi @dmitry-fedyuk

To clarify the design of the offsetGet() method, it was implemented following by the ArrayAccess interface to allow user to access any value that retrieve from Omise API by an array directly. i.e.

$charge = OmiseCharge::retrieve('chrg_id');
echo $charge['id']; // We want to have ArrayAccess::offsetGet(); to make this design.

So, for your request, to get the _values array at the whole. Currently, we are working on implement new Omise-PHP version, I would add this idea into the pipeline to consider add this feature in the future.

Btw, could you provide us more use case that you want to have function to access whole _values array? that we could consider the implementation from the use case.

Thanks & Cheers :D Nam

dmitrii-fediuk commented 7 years ago

I use the _values array at the whole to log it (other words, to log the Omise's API responses).

davidsneighbour commented 6 years ago

The _values array is marked as private which might break some functionality. I would also be interested in seeing a functionality to get the whole answer array (object) via a public function. Right now I just serialize the whole object and put it in a text field in the database for later de-serialization.

aashishgurung commented 1 year ago

You can use toArray() function from the version 2.16.0.

https://github.com/omise/omise-php/blob/master/lib/omise/res/obj/OmiseObject.php#L128

We are closing this issue. Thank you for raising this.