Code Duplication    Length = 20-22 lines in 2 locations

src/Http/BaseController.php 2 locations

@@ 335-354 (lines=20) @@
332
     *
333
     * @return ResponseInterface
334
     */
335
    protected static function deleteInRelationship(
336
        $parentIndex,
337
        string $relationshipName,
338
        $childIndex,
339
        string $childApiClass,
340
        ContainerInterface $container,
341
        ServerRequestInterface $request
342
    ): ResponseInterface {
343
        /** @var SchemaInterface $schemaClass */
344
        $schemaClass  = static::SCHEMA_CLASS;
345
        $modelRelName = $schemaClass::getRelationshipMapping($relationshipName);
346
        $hasChild     = self::createApi($container)->hasInRelationship($parentIndex, $modelRelName, $childIndex);
347
        if ($hasChild === false) {
348
            return static::createResponses($container, $request)->getCodeResponse(404);
349
        }
350
351
        $childApi = self::createApi($container, $childApiClass);
352
353
        return static::deleteImpl($childIndex, $container, $request, $childApi);
354
    }
355
356
    /** @noinspection PhpTooManyParametersInspection
357
     * @param int|string             $parentIndex
@@ 368-389 (lines=22) @@
365
     *
366
     * @return ResponseInterface
367
     */
368
    protected static function updateInRelationship(
369
        $parentIndex,
370
        string $relationshipName,
371
        $childIndex,
372
        array $attributes,
373
        array $toMany,
374
        string $childApiClass,
375
        ContainerInterface $container,
376
        ServerRequestInterface $request
377
    ): ResponseInterface {
378
        /** @var SchemaInterface $schemaClass */
379
        $schemaClass  = static::SCHEMA_CLASS;
380
        $modelRelName = $schemaClass::getRelationshipMapping($relationshipName);
381
        $hasChild     = self::createApi($container)->hasInRelationship($parentIndex, $modelRelName, $childIndex);
382
        if ($hasChild === false) {
383
            return static::createResponses($container, $request)->getCodeResponse(404);
384
        }
385
386
        $childApi = self::createApi($container, $childApiClass);
387
388
        return static::updateImpl($childIndex, $attributes, $toMany, $container, $request, $childApi);
389
    }
390
391
    /**
392
     * @param ContainerInterface $container