Code Duplication    Length = 22-22 lines in 2 locations

src/Http/BaseController.php 2 locations

@@ 228-249 (lines=22) @@
225
     * @throws ContainerExceptionInterface
226
     * @throws NotFoundExceptionInterface
227
     */
228
    protected static function readRelationshipWithClosure(
229
        Closure $apiHandler,
230
        string $relationshipName,
231
        ContainerInterface $container,
232
        ServerRequestInterface $request
233
    ): ResponseInterface {
234
        // By default no filters, sorts or includes are allowed from query. You can override this method to change it.
235
        $parser = static::configureOnReadRelationshipParser(
236
            $relationshipName,
237
            static::createQueryParser($container)
238
        )->parse($request->getQueryParams());
239
240
        $mapper  = static::createParameterMapper($container);
241
        $api     = $mapper->applyQueryParameters($parser, static::createApi($container));
242
        $relData = call_user_func($apiHandler, $api, $container);
243
244
        $responses = static::createResponses($container, $request, $parser->createEncodingParameters());
245
        $response  = $relData === null || ($relData instanceof PaginatedDataInterface && $relData->getData() === null) ?
246
            $responses->getCodeResponse(404) : $responses->getContentResponse($relData);
247
248
        return $response;
249
    }
250
251
    /**
252
     * @param Closure                $apiHandler
@@ 262-283 (lines=22) @@
259
     * @throws ContainerExceptionInterface
260
     * @throws NotFoundExceptionInterface
261
     */
262
    protected static function readRelationshipIdentifiersWithClosure(
263
        Closure $apiHandler,
264
        string $relationshipName,
265
        ContainerInterface $container,
266
        ServerRequestInterface $request
267
    ): ResponseInterface {
268
        // By default no filters, sorts or includes are allowed from query. You can override this method to change it.
269
        $parser = static::configureOnReadRelationshipIdentifiersParser(
270
            $relationshipName,
271
            static::createQueryParser($container)
272
        )->parse($request->getQueryParams());
273
274
        $mapper  = static::createParameterMapper($container);
275
        $api     = $mapper->applyQueryParameters($parser, static::createApi($container));
276
        $relData = call_user_func($apiHandler, $api, $container);
277
278
        $responses = static::createResponses($container, $request, $parser->createEncodingParameters());
279
        $response  = $relData === null || ($relData instanceof PaginatedDataInterface && $relData->getData() === null) ?
280
            $responses->getCodeResponse(404) : $responses->getIdentifiersResponse($relData);
281
282
        return $response;
283
    }
284
285
    /**
286
     * @param ContainerInterface $container