Code Duplication    Length = 28-28 lines in 3 locations

src/Http/JsonApiBaseController.php 3 locations

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