requestBody = json_decode($request->getContent(), true); self::validateJson(); $this->requestQuery = $request->query->all(); } /** * types are validated with gettype * @see gettype * * @param array $schemaRequired * @param array $schemaOptional */ public function validateBody(array $schemaRequired, array $schemaOptional = []): void { throw new AppException( ErrorCode::BAD_JSON, "Request body is missing required values", Response::HTTP_UNPROCESSABLE_ENTITY, ); } /** * types are validated with gettype * @see gettype * * @param array $schemaRequired * @param array $schemaOptional */ public function validateQuery(array $schemaRequired, array $schemaOptional = []): void { throw new AppException( ErrorCode::BAD_JSON, "Request query is missing required values", Response::HTTP_UNPROCESSABLE_ENTITY, ); } private function traverseRecursive(): void {} public static function validateJson(): void { if (json_last_error() !== JSON_ERROR_NONE) { throw new AppException( ErrorCode::NOT_JSON, "Request did not contain valid JSON", Response::HTTP_BAD_REQUEST, ); } } }