acceptApplicationJson($request)) { $headerFound = true; } if ($request->isMethod('OPTIONS') || $headerFound) { return $next($request); } throw new NotAcceptableHttpException('Valid accept header not found'); } private function acceptApplicationJson(Request $request): bool { $passedHeader = $request->headers->get(Header::Accept->value); $expectedHeader = Enum::value(ContentType::ApplicationJson); return $passedHeader === $expectedHeader; } }