Code Duplication    Length = 20-22 lines in 2 locations

src/Http/BaseController.php 2 locations

@@ 342-361 (lines=20) @@
339
     *
340
     * @return ResponseInterface
341
     */
342
    protected static function deleteInRelationship(
343
        $parentIndex,
344
        string $relationshipName,
345
        $childIndex,
346
        string $childApiClass,
347
        ContainerInterface $container,
348
        ServerRequestInterface $request
349
    ): ResponseInterface {
350
        /** @var SchemaInterface $schemaClass */
351
        $schemaClass  = static::SCHEMA_CLASS;
352
        $modelRelName = $schemaClass::getRelationshipMapping($relationshipName);
353
        $hasChild     = self::createApi($container)->hasInRelationship($parentIndex, $modelRelName, $childIndex);
354
        if ($hasChild === false) {
355
            return static::createResponses($container, $request)->getCodeResponse(404);
356
        }
357
358
        $childApi = self::createApi($container, $childApiClass);
359
360
        return static::deleteImpl($childIndex, $container, $request, $childApi);
361
    }
362
363
    /** @noinspection PhpTooManyParametersInspection
364
     * @param int|string             $parentIndex
@@ 375-396 (lines=22) @@
372
     *
373
     * @return ResponseInterface
374
     */
375
    protected static function updateInRelationship(
376
        $parentIndex,
377
        string $relationshipName,
378
        $childIndex,
379
        array $attributes,
380
        array $toMany,
381
        string $childApiClass,
382
        ContainerInterface $container,
383
        ServerRequestInterface $request
384
    ): ResponseInterface {
385
        /** @var SchemaInterface $schemaClass */
386
        $schemaClass  = static::SCHEMA_CLASS;
387
        $modelRelName = $schemaClass::getRelationshipMapping($relationshipName);
388
        $hasChild     = self::createApi($container)->hasInRelationship($parentIndex, $modelRelName, $childIndex);
389
        if ($hasChild === false) {
390
            return static::createResponses($container, $request)->getCodeResponse(404);
391
        }
392
393
        $childApi = self::createApi($container, $childApiClass);
394
395
        return static::updateImpl($childIndex, $attributes, $toMany, $container, $request, $childApi);
396
    }
397
398
    /**
399
     * @param ContainerInterface $container