Code Duplication    Length = 28-28 lines in 3 locations

src/Http/JsonApiBaseController.php 3 locations

@@ 268-295 (lines=28) @@
265
     *
266
     * @return ResponseInterface
267
     */
268
    protected static function addInRelationship(
269
        string $parentIndex,
270
        string $jsonRelName,
271
        string $modelRelName,
272
        ContainerInterface $container,
273
        ServerRequestInterface $request
274
    ): ResponseInterface {
275
        static::assertClassValueDefined(static::API_CLASS);
276
        static::assertClassValueDefined(static::SCHEMA_CLASS);
277
        static::assertClassValueDefined(static::ON_READ_QUERY_VALIDATION_RULES_CLASS);
278
        static::assertClassValueDefined(static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS);
279
280
        return static::defaultAddInRelationshipHandler(
281
            $parentIndex,
282
            $jsonRelName,
283
            $modelRelName,
284
            $request->getUri(),
285
            $request->getBody(),
286
            static::SCHEMA_CLASS,
287
            $container->get(ModelSchemaInfoInterface::class),
288
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
289
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
290
            static::defaultCreateApi($container, static::API_CLASS),
291
            $container->get(EncoderInterface::class),
292
            $container->get(FactoryInterface::class),
293
            $container->get(FormatterFactoryInterface::class)
294
        );
295
    }
296
297
    /**
298
     * @param string                 $parentIndex
@@ 306-333 (lines=28) @@
303
     *
304
     * @return ResponseInterface
305
     */
306
    protected static function deleteInRelationship(
307
        string $parentIndex,
308
        string $jsonRelName,
309
        string $modelRelName,
310
        ContainerInterface $container,
311
        ServerRequestInterface $request
312
    ): ResponseInterface {
313
        static::assertClassValueDefined(static::API_CLASS);
314
        static::assertClassValueDefined(static::SCHEMA_CLASS);
315
        static::assertClassValueDefined(static::ON_READ_QUERY_VALIDATION_RULES_CLASS);
316
        static::assertClassValueDefined(static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS);
317
318
        return static::defaultDeleteInRelationshipHandler(
319
            $parentIndex,
320
            $jsonRelName,
321
            $modelRelName,
322
            $request->getUri(),
323
            $request->getBody(),
324
            static::SCHEMA_CLASS,
325
            $container->get(ModelSchemaInfoInterface::class),
326
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
327
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
328
            static::defaultCreateApi($container, static::API_CLASS),
329
            $container->get(EncoderInterface::class),
330
            $container->get(FactoryInterface::class),
331
            $container->get(FormatterFactoryInterface::class)
332
        );
333
    }
334
335
    /**
336
     * @param string                 $parentIndex
@@ 344-371 (lines=28) @@
341
     *
342
     * @return ResponseInterface
343
     */
344
    protected static function replaceInRelationship(
345
        string $parentIndex,
346
        string $jsonRelName,
347
        string $modelRelName,
348
        ContainerInterface $container,
349
        ServerRequestInterface $request
350
    ): ResponseInterface {
351
        static::assertClassValueDefined(static::API_CLASS);
352
        static::assertClassValueDefined(static::SCHEMA_CLASS);
353
        static::assertClassValueDefined(static::ON_READ_QUERY_VALIDATION_RULES_CLASS);
354
        static::assertClassValueDefined(static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS);
355
356
        return static::defaultReplaceInRelationship(
357
            $parentIndex,
358
            $jsonRelName,
359
            $modelRelName,
360
            $request->getUri(),
361
            $request->getBody(),
362
            static::SCHEMA_CLASS,
363
            $container->get(ModelSchemaInfoInterface::class),
364
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
365
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
366
            static::defaultCreateApi($container, static::API_CLASS),
367
            $container->get(EncoderInterface::class),
368
            $container->get(FactoryInterface::class),
369
            $container->get(FormatterFactoryInterface::class)
370
        );
371
    }
372
}
373