Code Duplication    Length = 20-22 lines in 2 locations

src/Http/BaseController.php 2 locations

@@ 314-333 (lines=20) @@
311
     *
312
     * @return ResponseInterface
313
     */
314
    protected static function deleteInRelationship(
315
        $parentIndex,
316
        string $relationshipName,
317
        $childIndex,
318
        string $childApiClass,
319
        ContainerInterface $container,
320
        ServerRequestInterface $request
321
    ): ResponseInterface {
322
        /** @var SchemaInterface $schemaClass */
323
        $schemaClass  = static::SCHEMA_CLASS;
324
        $modelRelName = $schemaClass::getRelationshipMapping($relationshipName);
325
        $hasChild     = static::createApi($container)->hasInRelationship($parentIndex, $modelRelName, $childIndex);
326
        if ($hasChild === false) {
327
            return static::createResponses($container, $request)->getCodeResponse(404);
328
        }
329
330
        $childApi = static::createApi($container, $childApiClass);
331
332
        return static::deleteImpl($childIndex, $container, $request, $childApi);
333
    }
334
335
    /** @noinspection PhpTooManyParametersInspection
336
     * @param int|string             $parentIndex
@@ 347-368 (lines=22) @@
344
     *
345
     * @return ResponseInterface
346
     */
347
    protected static function updateInRelationship(
348
        $parentIndex,
349
        string $relationshipName,
350
        $childIndex,
351
        array $attributes,
352
        array $toMany,
353
        string $childApiClass,
354
        ContainerInterface $container,
355
        ServerRequestInterface $request
356
    ): ResponseInterface {
357
        /** @var SchemaInterface $schemaClass */
358
        $schemaClass  = static::SCHEMA_CLASS;
359
        $modelRelName = $schemaClass::getRelationshipMapping($relationshipName);
360
        $hasChild     = static::createApi($container)->hasInRelationship($parentIndex, $modelRelName, $childIndex);
361
        if ($hasChild === false) {
362
            return static::createResponses($container, $request)->getCodeResponse(404);
363
        }
364
365
        $childApi = static::createApi($container, $childApiClass);
366
367
        return static::updateImpl($childIndex, $attributes, $toMany, $container, $request, $childApi);
368
    }
369
370
    /**
371
     * @param ContainerInterface $container