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

Refactor decoder #24

Closed jenky closed 10 months ago

jenky commented 10 months ago

Introduced iterable as the new return type for decoders to allow for more flexible data structures, moving away from strict arrays. This allows the use of generators for on-demand data processing (cerbero/lazy-json, Laravel Lazy Collection), resulting in improved performance and reduced memory consumption when parsing large response bodies.

$response->decode(): iterable is now public instead of private to return the original value of the decoder.

Furthermore, decoders can implement the MapperInterface, allowing for the transformation of response bodies into objects. This facilitates object-oriented handling of response data using Data Transfer Objects (DTOs) or Value Objects (VOs). To retrieve your object, uses $response->object().

codecov[bot] commented 10 months ago

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (992f1e7) 84.77% compared to head (ec3bde0) 85.12%. Report is 1 commits behind head on main.

Files Patch % Lines
src/Mapper/GenericMapper.php 83.33% 2 Missing :warning:
src/Response.php 90.90% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #24 +/- ## ============================================ + Coverage 84.77% 85.12% +0.35% - Complexity 313 326 +13 ============================================ Files 38 39 +1 Lines 729 753 +24 ============================================ + Hits 618 641 +23 - Misses 111 112 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.