*/ final class BovineInventoryStatsProvider implements ProviderInterface { public function __construct( private BovineRepository $bovineRepository, private RequestStack $requestStack, ) {} public function provide(Operation $operation, array $uriVariables = [], array $context = []): BovineInventoryStats { $rawCaseId = $this->requestStack->getCurrentRequest()?->query->get('buildingCaseId'); $caseId = null !== $rawCaseId && ctype_digit((string) $rawCaseId) ? (int) $rawCaseId : null; $row = $this->bovineRepository->getInventoryStats($caseId); $stats = new BovineInventoryStats(); $stats->total = $row['total']; $stats->over24 = $row['over24']; $stats->between22And24 = $row['between22And24']; $stats->between20And22 = $row['between20And22']; return $stats; } }