Add a cache: constructor argument to Client and CallbackHandler - #16
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.x #16 +/- ##
============================================
+ Coverage 99.02% 99.03% +0.01%
- Complexity 190 192 +2
============================================
Files 26 26
Lines 511 517 +6
============================================
+ Hits 506 512 +6
Misses 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Aug 17, 2026
loevgaard
force-pushed
the
dx/cache-arg
branch
3 times, most recently
from
August 17, 2026 11:10
cf4ad71 to
d112b02
Compare
Wiring a Valinor cache meant building your own MapperBuilder/NormalizerBuilder AND remembering to run them through Client::configureMapperBuilder() / registerNormalizerTransformers(). Forgetting that compiles fine and fails at runtime (dates, superfluous keys) — a footgun for the most common production setup. - Client::__construct(..., ?Cache $cache = null): applied to the SDK's default mapper and normalizer builders (ignored for a builder passed explicitly — those are used as given, as before). - CallbackHandler::__construct($privateKey, ?$mapperBuilder, ?Cache $cache). - Client::defaultMapperBuilder(?Cache) / defaultNormalizerBuilder(?Cache) are now public (the callback side uses the former). - README "Production usage" leads with `cache:` and explains when to pass a builder instead. Refs #10 (finding 7).
loevgaard
force-pushed
the
dx/cache-arg
branch
from
August 17, 2026 11:10
d112b02 to
8e22262
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #10 (finding 7).
Why
Wiring a Valinor cache — the recommended production setup — meant building your own
MapperBuilder/NormalizerBuilderand remembering to run them throughClient::configureMapperBuilder()/registerNormalizerTransformers(). Forgetting that compiles fine and fails at runtime (dates don't map, superfluous keys throw). That's a footgun on the happy path.What
Client::__construct(..., ?Cache $cache = null)— applied to the SDK's default mapper and normalizer builders. Ignored for a builder passed explicitly (those are used as given, exactly as before), which the docblock spells out.CallbackHandler::__construct(string $privateKey, ?MapperBuilder $mapperBuilder = null, ?Cache $cache = null)— same idea for the callback side.Client::defaultMapperBuilder(?Cache)/defaultNormalizerBuilder(?Cache)are now public (the callback side uses the former; also handy for consumers who map raw arrays themselves).Purely additive (new optional trailing parameters). Tests: the cache directory is populated through both mapping and normalizing on the client and through the handler; the default builders map the SDK's date formats and strip nulls with and without a cache. (
QuickpayTestCasegainstempDir()/removeDir()helpers.)