Code Duplication    Length = 17-31 lines in 2 locations

src/Http/BaseController.php 2 locations

@@ 136-152 (lines=17) @@
133
    /**
134
     * @inheritdoc
135
     */
136
    public static function update(
137
        array $routeParams,
138
        ContainerInterface $container,
139
        ServerRequestInterface $request
140
    ): ResponseInterface {
141
        list ($updated, $index, $api) = static::updateImpl($routeParams, $container, $request);
142
143
        $responses = static::createResponses($container, $request);
144
        if ($updated > 0) {
145
            $modelData = $api->read($index);
146
            assert(!($modelData instanceof PaginatedDataInterface));
147
148
            return $responses->getContentResponse($modelData);
149
        }
150
151
        return $responses->getCodeResponse(404);
152
    }
153
154
    /**
155
     * @inheritdoc
@@ 423-453 (lines=31) @@
420
     * @throws ContainerExceptionInterface
421
     * @throws NotFoundExceptionInterface
422
     */
423
    protected static function updateInRelationship(
424
        $parentIndex,
425
        string $relationshipName,
426
        $childIndex,
427
        array $attributes,
428
        array $toMany,
429
        string $childApiClass,
430
        ContainerInterface $container,
431
        ServerRequestInterface $request
432
    ): ResponseInterface {
433
        /** @var CrudInterface $childApi */
434
        list ($updated, $childApi) = static::updateInRelationshipImpl(
435
            $parentIndex,
436
            $relationshipName,
437
            $childIndex,
438
            $attributes,
439
            $toMany,
440
            $childApiClass,
441
            $container
442
        );
443
444
        $responses = static::createResponses($container, $request);
445
        if ($updated > 0) {
446
            $modelData = $childApi->read($childIndex);
447
            assert(!($modelData instanceof PaginatedDataInterface));
448
449
            return $responses->getContentResponse($modelData);
450
        }
451
452
        return $responses->getCodeResponse(404);
453
    }
454
455
    /**
456
     * @param ContainerInterface $container