Code Duplication    Length = 30-30 lines in 3 locations

src/Http/JsonApiBaseController.php 3 locations

@@ 280-309 (lines=30) @@
277
     *
278
     * @return ResponseInterface
279
     */
280
    protected static function addInRelationship(
281
        string $parentIndex,
282
        string $jsonRelName,
283
        string $modelRelName,
284
        ContainerInterface $container,
285
        ServerRequestInterface $request
286
    ): ResponseInterface {
287
        static::assertClassValueDefined(static::API_CLASS);
288
        static::assertClassValueDefined(static::SCHEMA_CLASS);
289
        static::assertClassValueDefined(static::ON_READ_QUERY_VALIDATION_RULES_CLASS);
290
        static::assertClassValueDefined(static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS);
291
292
        return static::defaultAddInRelationshipHandler(
293
            $parentIndex,
294
            $jsonRelName,
295
            $modelRelName,
296
            $request->getUri(),
297
            $request->getBody(),
298
            static::SCHEMA_CLASS,
299
            $container->get(ModelSchemaInfoInterface::class),
300
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
301
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
302
            static::defaultCreateApi($container, static::API_CLASS),
303
            $container->get(SettingsProviderInterface::class),
304
            $container->get(JsonSchemasInterface::class),
305
            $container->get(EncoderInterface::class),
306
            $container->get(FactoryInterface::class),
307
            $container->get(FormatterFactoryInterface::class)
308
        );
309
    }
310
311
    /**
312
     * @param string                 $parentIndex
@@ 320-349 (lines=30) @@
317
     *
318
     * @return ResponseInterface
319
     */
320
    protected static function deleteInRelationship(
321
        string $parentIndex,
322
        string $jsonRelName,
323
        string $modelRelName,
324
        ContainerInterface $container,
325
        ServerRequestInterface $request
326
    ): ResponseInterface {
327
        static::assertClassValueDefined(static::API_CLASS);
328
        static::assertClassValueDefined(static::SCHEMA_CLASS);
329
        static::assertClassValueDefined(static::ON_READ_QUERY_VALIDATION_RULES_CLASS);
330
        static::assertClassValueDefined(static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS);
331
332
        return static::defaultDeleteInRelationshipHandler(
333
            $parentIndex,
334
            $jsonRelName,
335
            $modelRelName,
336
            $request->getUri(),
337
            $request->getBody(),
338
            static::SCHEMA_CLASS,
339
            $container->get(ModelSchemaInfoInterface::class),
340
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
341
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
342
            static::defaultCreateApi($container, static::API_CLASS),
343
            $container->get(SettingsProviderInterface::class),
344
            $container->get(JsonSchemasInterface::class),
345
            $container->get(EncoderInterface::class),
346
            $container->get(FactoryInterface::class),
347
            $container->get(FormatterFactoryInterface::class)
348
        );
349
    }
350
351
    /**
352
     * @param string                 $parentIndex
@@ 360-389 (lines=30) @@
357
     *
358
     * @return ResponseInterface
359
     */
360
    protected static function replaceInRelationship(
361
        string $parentIndex,
362
        string $jsonRelName,
363
        string $modelRelName,
364
        ContainerInterface $container,
365
        ServerRequestInterface $request
366
    ): ResponseInterface {
367
        static::assertClassValueDefined(static::API_CLASS);
368
        static::assertClassValueDefined(static::SCHEMA_CLASS);
369
        static::assertClassValueDefined(static::ON_READ_QUERY_VALIDATION_RULES_CLASS);
370
        static::assertClassValueDefined(static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS);
371
372
        return static::defaultReplaceInRelationship(
373
            $parentIndex,
374
            $jsonRelName,
375
            $modelRelName,
376
            $request->getUri(),
377
            $request->getBody(),
378
            static::SCHEMA_CLASS,
379
            $container->get(ModelSchemaInfoInterface::class),
380
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
381
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
382
            static::defaultCreateApi($container, static::API_CLASS),
383
            $container->get(SettingsProviderInterface::class),
384
            $container->get(JsonSchemasInterface::class),
385
            $container->get(EncoderInterface::class),
386
            $container->get(FactoryInterface::class),
387
            $container->get(FormatterFactoryInterface::class)
388
        );
389
    }
390
}
391