Code Duplication    Length = 28-28 lines in 2 locations

src/Http/JsonApiBaseController.php 2 locations

@@ 201-228 (lines=28) @@
198
     * @throws ContainerExceptionInterface
199
     * @throws NotFoundExceptionInterface
200
     */
201
    protected static function readRelationship(
202
        string $index,
203
        string $modelRelName,
204
        string $queryValRulesClass,
205
        ContainerInterface $container,
206
        ServerRequestInterface $request
207
    ): ResponseInterface {
208
        static::assertClassValueDefined(static::API_CLASS);
209
        static::assertClassValueDefined(static::SCHEMA_CLASS);
210
211
        $api     = static::defaultCreateApi($container, static::API_CLASS);
212
        $handler = function () use ($api, $index, $modelRelName) {
213
            return $api->readRelationship($index, $modelRelName);
214
        };
215
216
        return static::defaultReadRelationshipWithClosureHandler(
217
            $index,
218
            $handler,
219
            $request->getQueryParams(),
220
            $request->getUri(),
221
            static::defaultCreateQueryParser($container, $queryValRulesClass),
222
            static::defaultCreateParameterMapper($container, static::SCHEMA_CLASS),
223
            $api,
224
            $container->get(SettingsProviderInterface::class),
225
            $container->get(JsonSchemasInterface::class),
226
            $container->get(EncoderInterface::class)
227
        );
228
    }
229
230
    /**
231
     * @param string                 $index
@@ 242-269 (lines=28) @@
239
     * @throws ContainerExceptionInterface
240
     * @throws NotFoundExceptionInterface
241
     */
242
    protected static function readRelationshipIdentifiers(
243
        string $index,
244
        string $modelRelName,
245
        string $queryValRulesClass,
246
        ContainerInterface $container,
247
        ServerRequestInterface $request
248
    ): ResponseInterface {
249
        static::assertClassValueDefined(static::API_CLASS);
250
        static::assertClassValueDefined(static::SCHEMA_CLASS);
251
252
        $api     = static::defaultCreateApi($container, static::API_CLASS);
253
        $handler = function () use ($api, $index, $modelRelName) {
254
            return $api->readRelationship($index, $modelRelName);
255
        };
256
257
        return static::defaultReadRelationshipIdentifiersWithClosureHandler(
258
            $index,
259
            $handler,
260
            $request->getQueryParams(),
261
            $request->getUri(),
262
            static::defaultCreateQueryParser($container, $queryValRulesClass),
263
            static::defaultCreateParameterMapper($container, static::SCHEMA_CLASS),
264
            $api,
265
            $container->get(SettingsProviderInterface::class),
266
            $container->get(JsonSchemasInterface::class),
267
            $container->get(EncoderInterface::class)
268
        );
269
    }
270
271
    /**
272
     * @param string                 $parentIndex