Repository navigation
refactor(metadata): split MetadataService patch, upsert and filter checks into named steps - #1072
Open
rubenvdlinde wants to merge 2 commits into
Open
rubenvdlinde wants to merge 2 commits into
rubenvdlinde wants to merge 2 commits into
Conversation
… before the split Assisted-by: ClaudeCode:claude-opus-5-5
…ge checks into named steps Assisted-by: ClaudeCode:claude-opus-5-5
rubenvdlinde
requested review from
WilcoLouwerse,
bbrands02 and
rjzondervan
as code owners
November 11, 2026 18:15
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.
What changed
MetadataServicereads as named steps instead of seven branchy methods:updateFieldDefinitionrefuses a key rename, loads the field and appliespatchLabel,patchSortOrder,patchRequiredandpatchOptionsin the original order before stamping and saving.setMetadataForDashboardresolves each key withfieldForKey(empty / unknown key messages unchanged), validates the value and hands it to a newMetadataValueWriter, a small final run object built for this one write, which clears the row of an empty optional value or upserts it.extractUuid→entityUuid/rowUuid;matchesNumberRange→withinNumberRange;matchesDateRange→withinDateRange(isOnOrAfter,isOnOrBefore);assertOptionsShape→isSelectType;assertSelectOptions→assertOptionEntries.Behaviour is unchanged: the same validation messages in the same precedence, the same deletes and upserts in the same order, the same filter matches.
Characterisation tests
tests/Unit/Service/MetadataServiceBranchesTest.phpwas committed first, against the old code, and passes before and after: a rename refused before the field is read, every patch key (and an ignored one), therequiredcasting, the invalid patches with their exact messages and order (label before options, scalar / null / empty / non-string / empty-string options, options on a text field), the empty and unknown metadata keys, the clear-versus-upsert sequence across optional, absent, required and integer keys, the number and date range criteria (each bound alone, both, empty range, exact, non-numeric) and UUID lookup on entities, null-UUID entities, plain objects and rows.What ran
vendor/bin/phpunit -c phpunit.xml --no-coverage tests/Unit: 2776 tests OK (13 skipped, as on development).vendor/bin/phpcsandvendor/bin/phpstan analyseon the touched lib files: clean.vendor/bin/phpmdonMetadataService: one new finding,TooManyMethods(29 methods against a limit of 25), the cost of turning long methods into named private steps;composer phpmdis already red on development for other classes.Figures (touched files
lib/Service/MetadataService.php,lib/Service/MetadataValueWriter.php)MetadataValueWriterdepends onMetadataValueMapper(already used byMetadataService) andMetadataField; nothing else depends on it butMetadataService. App-wide: unit complexity 4.02 → 4.10, unit size 3.40 → 3.42, module coupling unchanged.Maintainability floor: compare against development holds.
AI-assisted: prepared with Claude Code (claude-opus-5-5); reviewed by a maintainer before merge.
Generated by Claude Code