astrotomic/php-conditional-proxy
A lightweight conditional proxy for PHP that lets you chain method calls on any object and execute them only when your conditions pass. Use when/unless-style checks to keep optional logic clean, fluent, and free of scattered if statements.
Architecture fit
if blocks. This is relevant wherever the codebase relies on builders, pipelines, query composition, or any return $this API.Conditionable-style helpers; the conceptual overlap means developers will recognize the intent immediately. It is not an architectural component and should not be positioned as one.Integration feasibility
Technical risk
__call/magic dispatch, which degrades static analysis (PHPStan/Psalm), IDE completion, and go-to-definition. Teams with strict static-analysis gates will need baseline entries or stubs.Key questions
$this, the target object, or the callee's return value — and does that satisfy our existing builder contracts?when/unless symmetry, multi-condition composition, and nested chains, or only a single boolean gate?__call, __get, or Laravel's Conditionable?Stack fit
when() styles that read identically but behave differently.Migration path
if guards.if blocks; the readability gain is real but localized, and wholesale churn adds review cost without proportional benefit.Compatibility
Conditionable and any custom __call implementations in our base classes; magic-method collisions are the most likely integration defect.Sequencing
if) and only then expand usage.Maintenance
Support
Scaling
Failure modes
__call resolution path routes calls to the wrong target or throws.Ramp-up
if is clearer — to prevent the idiom from spreading into places where it hurts readability rather than helping it.How can I help you explore Laravel packages today?