Skip to content

v2.1.7 — Phase 9.11: HTTP/URL/Support utility extraction

Choose a tag to compare

@mexiter mexiter released this 25 Apr 14:01
· 67 commits to epic/refactor-april since this release

Phase 9.11 — HTTP / URL / Support utility extraction

Seven stateless helpers leave the god-class for dedicated single-responsibility classes under DataFlair\Toplists\Http\ and DataFlair\Toplists\Support\.

New classes

  • Support\UrlValidator — replaces is_local_url(). Classifies hosts as local-dev (.test, .local, .localhost, .invalid, .example, localhost, 127.0.0.1).
  • Support\UrlTransformer — replaces maybe_force_https(). Rewrites http:// → https:// for non-local URLs.
  • Support\EnvironmentDetector — replaces is_running_in_docker(). Three-way Docker detection.
  • Support\RelativeTimeFormatter — replaces time_ago() + time_until(). "3 minutes ago" / "in 3 minutes" labels.
  • Http\ApiBaseUrlDetector — replaces get_api_base_url(). Three-tier resolution (stored option → endpoints option → fallback).
  • Http\BrandsApiUrlBuilder — replaces get_brands_api_url(). Respects dataflair_brands_api_version.
  • Http\ApiErrorFormatter — replaces build_detailed_api_error(). Status-code switch with admin-UI guidance.

Stats

  • dataflair-toplists.php: 1,772 → 1,700 LOC.
  • Tests: 503 → 553 (1,213 assertions), all green.
  • 50 new unit tests pin behaviour at the boundary.

Invariants preserved

  • Render is still read-only; cron is still removed; HTTPS-force / Docker detection / human-readable error formatting all behave exactly as before.
  • The eight extracted god-class methods become one-line delegators — call sites and behaviour unchanged.
  • No public option, table, shortcode, AJAX action, or REST route changed.

Branch

This release lives on epic/refactor-april. main is intentionally untouched until end-to-end QA on the epic completes.

Next

Phase 9.12 (v2.1.8) — Shortcode + campaign redirect extraction.
Phase 9.13 (v3.0.0) — God-class symbol removal.