omise-php icon indicating copy to clipboard operation
omise-php copied to clipboard

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

Open dmitrii-fediuk opened this issue 9 years ago • 3 comments

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

dmitrii-fediuk avatar Jan 09 '17 17:01 dmitrii-fediuk

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

guzzilar avatar Jan 19 '17 08:01 guzzilar

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

dmitrii-fediuk avatar Jan 19 '17 08:01 dmitrii-fediuk

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.

davidsneighbour avatar Oct 11 '18 11:10 davidsneighbour

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.

aashishgurung avatar Mar 10 '23 08:03 aashishgurung