Code Duplication    Length = 26-26 lines in 2 locations

src/Http/JsonApiBaseController.php 2 locations

@@ 191-216 (lines=26) @@
188
     * @throws ContainerExceptionInterface
189
     * @throws NotFoundExceptionInterface
190
     */
191
    protected static function readRelationship(
192
        string $index,
193
        string $modelRelName,
194
        string $queryValRulesClass,
195
        ContainerInterface $container,
196
        ServerRequestInterface $request
197
    ): ResponseInterface {
198
        static::assertClassValueDefined(static::API_CLASS);
199
        static::assertClassValueDefined(static::SCHEMA_CLASS);
200
201
        $api     = static::defaultCreateApi($container, static::API_CLASS);
202
        $handler = function () use ($api, $index, $modelRelName) {
203
            return $api->readRelationship($index, $modelRelName);
204
        };
205
206
        return static::defaultReadRelationshipWithClosureHandler(
207
            $index,
208
            $handler,
209
            $request->getQueryParams(),
210
            $request->getUri(),
211
            static::defaultCreateQueryParser($container, $queryValRulesClass),
212
            static::defaultCreateParameterMapper($container, static::SCHEMA_CLASS),
213
            $api,
214
            $container->get(EncoderInterface::class)
215
        );
216
    }
217
218
    /**
219
     * @param string                 $index
@@ 230-255 (lines=26) @@
227
     * @throws ContainerExceptionInterface
228
     * @throws NotFoundExceptionInterface
229
     */
230
    protected static function readRelationshipIdentifiers(
231
        string $index,
232
        string $modelRelName,
233
        string $queryValRulesClass,
234
        ContainerInterface $container,
235
        ServerRequestInterface $request
236
    ): ResponseInterface {
237
        static::assertClassValueDefined(static::API_CLASS);
238
        static::assertClassValueDefined(static::SCHEMA_CLASS);
239
240
        $api     = static::defaultCreateApi($container, static::API_CLASS);
241
        $handler = function () use ($api, $index, $modelRelName) {
242
            return $api->readRelationship($index, $modelRelName);
243
        };
244
245
        return static::defaultReadRelationshipIdentifiersWithClosureHandler(
246
            $index,
247
            $handler,
248
            $request->getQueryParams(),
249
            $request->getUri(),
250
            static::defaultCreateQueryParser($container, $queryValRulesClass),
251
            static::defaultCreateParameterMapper($container, static::SCHEMA_CLASS),
252
            $api,
253
            $container->get(EncoderInterface::class)
254
        );
255
    }
256
257
    /**
258
     * @param string                 $parentIndex