feat: add Comuna enum with the 346 comunas of Chile - #24
Conversation
- Int-backed by the official CUT code (SUBDERE, Planilla CUT_2018_v04) - Generated and validated against the official SUBDERE spreadsheet - officialName(), code() (zero-padded), region() derived from the CUT prefix - fromName() case/accent-insensitive lookup, inRegion() and options() for selects - Region::comunas() helper - Fixed two missing accents present in the source spreadsheet (Los Ángeles, Los Álamos) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WvDYWr2Tx3diCV3NXGrKRX
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a ChangesComuna support
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/Comuna.php (1)
793-807: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocblock key description could be clearer.
"[code => official name]" is ambiguous next to the
code()method, which returns a zero-padded string ('01101'), whereas this array is keyed by the raw intvalue(1101). Worth wording it as "[value => official name]" to avoid confusion, since PHP would coerce a numeric-string code key back to int anyway.📝 Suggested docblock tweak
/** - * Comunas as an array suitable for HTML selects: [code => official name]. + * Comunas as an array suitable for HTML selects: [value => official name]. * Optionally filtered by region. * * `@return` array<int, string> */🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Comuna.php` around lines 793 - 807, Clarify the `options()` docblock by changing the return description from “[code => official name]” to “[value => official name]”, accurately reflecting that keys use the raw integer `value` rather than the zero-padded string returned by `code()`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/Comuna.php`:
- Around line 793-807: Clarify the `options()` docblock by changing the return
description from “[code => official name]” to “[value => official name]”,
accurately reflecting that keys use the raw integer `value` rather than the
zero-padded string returned by `code()`.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: aa85e30b-fa0d-4968-b242-a3e4450c4930
📒 Files selected for processing (4)
README.mdsrc/Comuna.phpsrc/Region.phptests/Unit/ComunaTest.php
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WvDYWr2Tx3diCV3NXGrKRX
Summary
Adds a
Comunaenum with the 346 comunas of Chile, following the same design as theRegionenum from #23.region()is derived arithmetically — no duplicated data.officialName()— official spelling with accents.code()— zero-padded five-digit format used in official documents ('01101').fromName('ñuñoa')— case- and accent-insensitive lookup.inRegion(Region $r)/Region::comunas()— comunas of a region.options(?Region $r)—[code => name]arrays ready for HTML selects.Data provenance
The enum was generated from the official SUBDERE spreadsheet (
CUT_2018_v04.xls, the latest published CUT), not hand-typed. The community dataset initially considered (bdcut-cl) was discarded after cross-validation revealed it still had the Ñuble comunas under their pre-2018 codes (08xxx instead of 16xxx).Two known typos in the SUBDERE file (missing accents in "Los Angeles" and "Los Alamos") were corrected to their official spellings.
Test plan
🤖 Generated with Claude Code
https://claude.ai/code/session_01WvDYWr2Tx3diCV3NXGrKRX
Summary by CodeRabbit