Audit item #8. StationController::index was ~100 lines doing the haversine join, in-PHP filter/sort/group, search-row write, and prediction call — well past the "thin orchestrator" line in .claude/rules/architecture.md. - App\Services\StationSearch\SearchCriteria — DTO (lat/lng/fuelType/ radiusKm/sort) - App\Services\StationSearch\SearchResult — DTO (stations, prices summary, reliability counts, prediction payload) - App\Services\StationSearch\StationSearchService::search(criteria, ?user, ?ipHash) — owns the haversine query, the per-row reliability memoisation, sort, count, search-row logging, and the tier-gated prediction. The controller now resolves coordinates, builds a SearchCriteria, calls the service, and shapes the JSON response. Down from 154 → 71 lines. Public API contract unchanged — all 15 StationController tests pass without modification. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
17 lines
303 B
PHP
17 lines
303 B
PHP
<?php
|
|
|
|
namespace App\Services\StationSearch;
|
|
|
|
use App\Enums\FuelType;
|
|
|
|
final readonly class SearchCriteria
|
|
{
|
|
public function __construct(
|
|
public float $lat,
|
|
public float $lng,
|
|
public FuelType $fuelType,
|
|
public float $radiusKm,
|
|
public string $sort,
|
|
) {}
|
|
}
|