Code Duplication    Length = 20-22 lines in 2 locations

src/Http/BaseController.php 2 locations

@@ 324-343 (lines=20) @@
321
     *
322
     * @return ResponseInterface
323
     */
324
    protected static function deleteInRelationship(
325
        $parentIndex,
326
        string $relationshipName,
327
        $childIndex,
328
        string $childApiClass,
329
        ContainerInterface $container,
330
        ServerRequestInterface $request
331
    ): ResponseInterface {
332
        /** @var SchemaInterface $schemaClass */
333
        $schemaClass  = static::SCHEMA_CLASS;
334
        $modelRelName = $schemaClass::getRelationshipMapping($relationshipName);
335
        $hasChild     = self::createApi($container)->hasInRelationship($parentIndex, $modelRelName, $childIndex);
336
        if ($hasChild === false) {
337
            return static::createResponses($container, $request)->getCodeResponse(404);
338
        }
339
340
        $childApi = self::createApi($container, $childApiClass);
341
342
        return static::deleteImpl($childIndex, $container, $request, $childApi);
343
    }
344
345
    /** @noinspection PhpTooManyParametersInspection
346
     * @param int|string             $parentIndex
@@ 357-378 (lines=22) @@
354
     *
355
     * @return ResponseInterface
356
     */
357
    protected static function updateInRelationship(
358
        $parentIndex,
359
        string $relationshipName,
360
        $childIndex,
361
        array $attributes,
362
        array $toMany,
363
        string $childApiClass,
364
        ContainerInterface $container,
365
        ServerRequestInterface $request
366
    ): ResponseInterface {
367
        /** @var SchemaInterface $schemaClass */
368
        $schemaClass  = static::SCHEMA_CLASS;
369
        $modelRelName = $schemaClass::getRelationshipMapping($relationshipName);
370
        $hasChild     = self::createApi($container)->hasInRelationship($parentIndex, $modelRelName, $childIndex);
371
        if ($hasChild === false) {
372
            return static::createResponses($container, $request)->getCodeResponse(404);
373
        }
374
375
        $childApi = self::createApi($container, $childApiClass);
376
377
        return static::updateImpl($childIndex, $attributes, $toMany, $container, $request, $childApi);
378
    }
379
380
    /**
381
     * @param ContainerInterface $container