From de725bf0189cb60daeea23ebb566e3e8d3a1604a Mon Sep 17 00:00:00 2001 From: Daan Rijpkema Date: Wed, 29 Jul 2026 13:37:19 +0200 Subject: [PATCH] Extract core option lookup --- bluem.php | 9 ++------- docs/refactor-increments.md | 22 +++++++++++----------- src/Settings/BluemOptionLookup.php | 17 +++++++++++++++++ tests/Unit/BluemOptionLookupTest.php | 25 +++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 src/Settings/BluemOptionLookup.php create mode 100644 tests/Unit/BluemOptionLookupTest.php diff --git a/bluem.php b/bluem.php index ab6af7b..4e276e5 100644 --- a/bluem.php +++ b/bluem.php @@ -51,6 +51,7 @@ use Bluem\Wordpress\Observability\BluemActivationNotifier; use Bluem\Wordpress\Observability\BluemSentry; use Bluem\Wordpress\Support\BluemComposerDependencyVersion; +use Bluem\Wordpress\Settings\BluemOptionLookup; /** * Create a Bluem client while allowing acceptance tests to replace only its @@ -1444,13 +1445,7 @@ function bluem_woocommerce_show_general_profile_fields() { // Settings functions function bluem_woocommerce_get_option( $key ) { - $options = bluem_woocommerce_get_core_options(); - - if ( array_key_exists( $key, $options ) ) { - return $options[ $key ]; - } - - return false; + return (new BluemOptionLookup(bluem_woocommerce_get_core_options()))->get($key); } function bluem_woocommerce_settings_render_environment() { diff --git a/docs/refactor-increments.md b/docs/refactor-increments.md index 63e226b..7cddf22 100644 --- a/docs/refactor-increments.md +++ b/docs/refactor-increments.md @@ -12,15 +12,15 @@ functions as compatibility adapters during the migration. 6. [x] Extract Composer dependency version lookup into a testable support service. 7. [ ] Extract support-report environment collection behind injectable WordPress and WooCommerce readers. 8. [ ] Extract support-report trace normalization into a pure trace formatter. -9. [ ] Extract core plugin option definitions and option lookup into a settings object. -10. [ ] Extract payment, mandate, and iDIN settings access behind feature-specific settings objects. -11. [ ] Extract Bluem request persistence from `bluem-db.php` into a request repository. -12. [ ] Extract request logging and link persistence from `bluem-db.php` into focused repositories. -13. [ ] Extract payment callback status resolution and order-transition orchestration. -14. [ ] Extract iDIN validation and result handling into an identity workflow service. -15. [ ] Extract mandate request and callback orchestration into a mandate workflow service. -16. [ ] Extract Contact Form 7 and Gravity Forms flows into integration adapters. -17. [ ] Move admin request rendering and navigation behind presentation services. +9. [x] Extract core plugin option lookup into a small settings accessor. +10. [ ] Extract core plugin option definitions into a settings schema object. +11. [ ] Extract payment, mandate, and iDIN settings access behind feature-specific settings objects. +12. [ ] Extract Bluem request persistence from `bluem-db.php` into a request repository. +13. [ ] Extract request logging and link persistence from `bluem-db.php` into focused repositories. +14. [ ] Extract payment callback status resolution and order-transition orchestration. +15. [ ] Extract iDIN validation and result handling into an identity workflow service. +16. [ ] Extract mandate request and callback orchestration into a mandate workflow service. +17. [ ] Extract Contact Form 7 and Gravity Forms flows into integration adapters. +18. [ ] Move admin request rendering and navigation behind presentation services. -The next increment is support-report environment collection, with WordPress and -WooCommerce dependencies kept behind injectable readers. +The next increment is the larger core option schema extraction. diff --git a/src/Settings/BluemOptionLookup.php b/src/Settings/BluemOptionLookup.php new file mode 100644 index 0000000..439813d --- /dev/null +++ b/src/Settings/BluemOptionLookup.php @@ -0,0 +1,17 @@ +options) + ? $this->options[$key] + : false; + } +} diff --git a/tests/Unit/BluemOptionLookupTest.php b/tests/Unit/BluemOptionLookupTest.php new file mode 100644 index 0000000..7405322 --- /dev/null +++ b/tests/Unit/BluemOptionLookupTest.php @@ -0,0 +1,25 @@ + ['default' => 'test'], + 'senderID' => ['default' => ''], + ]); + + self::assertSame(['default' => 'test'], $lookup->get('environment')); + self::assertSame(['default' => ''], $lookup->get('senderID')); + } + + public function testMissingOptionsReturnFalseForCompatibility(): void + { + self::assertFalse((new BluemOptionLookup([]))->get('missing')); + } +}