phanxipang / fansipan

A simple package that allows you to write your API integrations or SDKs in a elegant way.
https://phanxipang.github.io/fansipan
MIT License
83 stars 2 forks source link

Improve decoder #4

Closed jenky closed 1 year ago

jenky commented 1 year ago

Detailed description

Improve decoder decode method to return iterable instead of array

Context

This allows to map the response body to DTOs

jenky commented 1 year ago

Close due to the fact that your DTO now have to implements an interface to be treated as iterable. It also remove the ability to access to value by using array syntax from IDE suggestions, for i.e: $data['foo'].

DTO can have static method such as fromResponse(Response $response): self to create new instance of it self.