Skip to content

Simplify how we load and save files in data/#1629

Merged
henriquemoody merged 1 commit intoRespect:mainfrom
henriquemoody:core/data_loader
Jan 26, 2026
Merged

Simplify how we load and save files in data/#1629
henriquemoody merged 1 commit intoRespect:mainfrom
henriquemoody:core/data_loader

Conversation

@henriquemoody
Copy link
Member

We had different ways of saving and loading files from data/, so I decided to unify them to simplify things. I repurposed the DomainInfo class and named it DataLoader, so we can use the same class to load anything from the data/ directory.

@henriquemoody henriquemoody force-pushed the core/data_loader branch 2 times, most recently from 55bb7fa to 91ffb5d Compare January 26, 2026 19:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors data file loading and saving by introducing two new helper classes: DataLoader (replacing DomainInfo) and DataSaver. The goal is to unify and simplify how data files in the data/ directory are accessed and updated.

Changes:

  • Introduced DataLoader class to centralize data file loading with caching
  • Introduced DataSaver class to standardize data file saving across update commands
  • Removed DomainInfo class and migrated its functionality to DataLoader
  • Updated validators (Tld, PostalCode, PublicDomainSuffix) to use the new DataLoader
  • Updated command classes to use DataSaver for file writing

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Helpers/DataLoader.php New helper class providing unified data file loading with static caching
src-dev/Helpers/DataSaver.php New helper class providing standardized data file writing with consistent formatting
tests/unit/Helpers/DataLoaderTest.php Unit tests for the new DataLoader functionality
src/Helpers/DomainInfo.php Removed legacy domain-specific data loader
src/Validators/Tld.php Refactored to use DataLoader and Envelope pattern with Call/In validators
src/Validators/PublicDomainSuffix.php Updated to use DataLoader instead of DomainInfo
src/Validators/PostalCode.php Updated to use DataLoader for postal code data
src-dev/Commands/UpdatePostalCodesCommand.php Refactored to use DataSaver dependency injection
src-dev/Commands/UpdateDomainToplevelCommand.php Refactored to use DataSaver dependency injection
src-dev/Commands/UpdateDomainSuffixesCommand.php Refactored to use DataSaver dependency injection
bin/console Updated to instantiate and inject DataSaver into commands

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@henriquemoody henriquemoody force-pushed the core/data_loader branch 2 times, most recently from c75bba1 to 9affc71 Compare January 26, 2026 19:26
@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.01%. Comparing base (819d734) to head (4390e4f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1629      +/-   ##
============================================
+ Coverage     97.93%   98.01%   +0.07%     
+ Complexity      960      956       -4     
============================================
  Files           197      197              
  Lines          2230     2219      -11     
============================================
- Hits           2184     2175       -9     
+ Misses           46       44       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

We had different ways of saving and loading files from `data/`, so I decided to
unify them to simplify things. I repurposed the `DomainInfo` class and named it
`DataLoader`, so we can use the same class to load anything from the `data/`
directory.
@henriquemoody henriquemoody merged commit 4390e4f into Respect:main Jan 26, 2026
7 of 8 checks passed
@henriquemoody henriquemoody deleted the core/data_loader branch January 26, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants