Repository navigation
refactor: split SplitWorldHeritageJson::handle() into smaller methods / handle()メソッドの分割 - #584
Merged
zigzagdev merged 2 commits intoOct 6, 2026
Conversation
…e A) The 6 output payloads (sites/countries/pivot/images/judgements/exceptions) all shared the same meta block shape (schema/source_raw/generated_at/ rows_scanned) with only a few payload-specific extra fields. Extract that repetition into buildPayload() to shrink the giant handle() method. Verified against a fixture run that the generated JSON meta blocks are unchanged in key order and values.
Move the 220-line per-row validation/normalization loop out of handle() into its own processRows() method, returning the collected sites/ countries/pivot/images/judgements/exceptions and counters as an array. handle() is now orchestration only: read input, delegate row processing, build payloads, write output. Verified against fixture runs covering the happy path, skip branches (missing/non-numeric id_no), and --strict mode's failure propagation, plus the full test suite (226 passed).
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.
Motivation / 目的
SplitWorldHeritageJson::handle() had grown to roughly 550 lines, mixing
input parsing, a 220-line per-row validation/normalization loop, and
repetitive output-payload assembly all in one method. This made the
command hard to read and reason about.
SplitWorldHeritageJson::handle()が約550行に肥大化し、入力パース・220行の
行単位の検証/正規化ループ・繰り返しの多い出力ペイロード組み立てが1つの
メソッドに混在していました。可読性・保守性を改善します。
What I have done / 実施内容
6 output payloads: sites/countries/pivot/images/judgements/exceptions)
into a
buildPayload()helperown
processRows()method, returning the collected collections andcounters as an array.
handle()is now orchestration only: read input,delegate to processRows(), build payloads, write output
Test Results / テスト結果
php artisan test(full suite): 226 passed, no regressionsworld-heritage:split-jsonthatgenerated JSON meta blocks are byte-identical in key order/values, and
that skip branches (missing/non-numeric id_no) and
--strictmode'sfailure propagation still behave correctly end-to-end