Code Duplication    Length = 29-29 lines in 2 locations

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

@@ 83-111 (lines=29) @@
80
     * @throws InvalidDataTypeException
81
     * @throws InvalidInterfaceException
82
     */
83
    public static function handleRequestGetAll(WP_REST_Request $request, $version, $model_name)
84
    {
85
        $controller = LoaderFactory::getLoader()->getNew('EventEspresso\core\libraries\rest_api\controllers\model\Read');
86
        try {
87
            $controller->setRequestedVersion($version);
88
            if (! $controller->getModelVersionInfo()->isModelNameInThisVersion($model_name)) {
89
                return $controller->sendResponse(
90
                    new WP_Error(
91
                        'endpoint_parsing_error',
92
                        sprintf(
93
                            __(
94
                                'There is no model for endpoint %s. Please contact event espresso support',
95
                                'event_espresso'
96
                            ),
97
                            $model_name
98
                        )
99
                    )
100
                );
101
            }
102
            return $controller->sendResponse(
103
                $controller->getEntitiesFromModel(
104
                    $controller->getModelVersionInfo()->loadModel($model_name),
105
                    $request
106
                )
107
            );
108
        } catch (Exception $e) {
109
            return $controller->sendResponse($e);
110
        }
111
    }
112
113
114
    /**
@@ 264-292 (lines=29) @@
261
     * @throws InvalidInterfaceException
262
     * @throws InvalidArgumentException
263
     */
264
    public static function handleRequestGetOne(WP_REST_Request $request, $version, $model_name)
265
    {
266
        $controller = LoaderFactory::getLoader()->getNew('EventEspresso\core\libraries\rest_api\controllers\model\Read');
267
        try {
268
            $controller->setRequestedVersion($version);
269
            if (! $controller->getModelVersionInfo()->isModelNameInThisVersion($model_name)) {
270
                return $controller->sendResponse(
271
                    new WP_Error(
272
                        'endpoint_parsing_error',
273
                        sprintf(
274
                            __(
275
                                'There is no model for endpoint %s. Please contact event espresso support',
276
                                'event_espresso'
277
                            ),
278
                            $model_name
279
                        )
280
                    )
281
                );
282
            }
283
            return $controller->sendResponse(
284
                $controller->getEntityFromModel(
285
                    $controller->getModelVersionInfo()->loadModel($model_name),
286
                    $request
287
                )
288
            );
289
        } catch (Exception $e) {
290
            return $controller->sendResponse($e);
291
        }
292
    }
293
294
295
    /**