Code Duplication    Length = 17-18 lines in 2 locations

core/libraries/rest_api/controllers/model/Write.php 2 locations

@@ 383-400 (lines=18) @@
380
     * @param WP_REST_Request $request
381
     * @return WP_REST_Response
382
     */
383
    public static function handleRequestAddRelation(WP_REST_Request $request, $version, $model_name, $related_model_name)
384
    {
385
        $controller = new Write();
386
        try {
387
            $controller->setRequestedVersion($version);
388
            $main_model = $controller->validateModel($model_name);
389
            $controller->validateModel($related_model_name);
390
            return $controller->sendResponse(
391
                $controller->addRelation(
392
                    $main_model,
393
                    $main_model->related_settings_for($related_model_name),
394
                    $request
395
                )
396
            );
397
        } catch (Exception $e) {
398
            return $controller->sendResponse($e);
399
        }
400
    }
401
402
    /**
403
     * Adds a relation between the two model specified model objects.
@@ 462-478 (lines=17) @@
459
     * @param WP_REST_Request $request
460
     * @return WP_REST_Response
461
     */
462
    public static function handleRequestRemoveRelation(WP_REST_Request $request, $version, $model_name, $related_model_name)
463
    {
464
        $controller = new Write();
465
        try {
466
            $controller->setRequestedVersion($version);
467
            $main_model = $controller->getModelVersionInfo()->loadModel($model_name);
468
            return $controller->sendResponse(
469
                $controller->removeRelation(
470
                    $main_model,
471
                    $main_model->related_settings_for($related_model_name),
472
                    $request
473
                )
474
            );
475
        } catch (Exception $e) {
476
            return $controller->sendResponse($e);
477
        }
478
    }
479
480
    /**
481
     * Adds a relation between the two model specified model objects.