Code Duplication    Length = 11-15 lines in 3 locations

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

@@ 138-148 (lines=11) @@
135
    {
136
        Capabilities::verifyAtLeastPartialAccessTo($model, EEM_Base::caps_edit, 'create');
137
        $default_cap_to_check_for = EE_Restriction_Generator_Base::get_default_restrictions_cap();
138
        if (! current_user_can($default_cap_to_check_for)) {
139
            throw new RestException(
140
                'rest_cannot_create_' . EEH_Inflector::pluralize_and_lower(($model->get_this_model_name())),
141
                sprintf(
142
                    esc_html__(
143
                        // @codingStandardsIgnoreStart
144
                        'For now, only those with the admin capability to "%1$s" are allowed to use the REST API to insert data into Event Espresso.',
145
                        // @codingStandardsIgnoreEnd
146
                        'event_espresso'
147
                    ),
148
                    $default_cap_to_check_for
149
                ),
150
                array('status' => 403)
151
            );
@@ 191-201 (lines=11) @@
188
    {
189
        Capabilities::verifyAtLeastPartialAccessTo($model, EEM_Base::caps_edit, 'edit');
190
        $default_cap_to_check_for = EE_Restriction_Generator_Base::get_default_restrictions_cap();
191
        if (! current_user_can($default_cap_to_check_for)) {
192
            throw new RestException(
193
                'rest_cannot_edit_' . EEH_Inflector::pluralize_and_lower(($model->get_this_model_name())),
194
                sprintf(
195
                    esc_html__(
196
                        // @codingStandardsIgnoreStart
197
                        'For now, only those with the admin capability to "%1$s" are allowed to use the REST API to update data into Event Espresso.',
198
                        // @codingStandardsIgnoreEnd
199
                        'event_espresso'
200
                    ),
201
                    $default_cap_to_check_for
202
                ),
203
                array('status' => 403)
204
            );
@@ 238-252 (lines=15) @@
235
    {
236
        Capabilities::verifyAtLeastPartialAccessTo($model, EEM_Base::caps_delete, 'delete');
237
        $default_cap_to_check_for = EE_Restriction_Generator_Base::get_default_restrictions_cap();
238
        if (! current_user_can($default_cap_to_check_for)) {
239
            throw new RestException(
240
                'rest_cannot_delete_' . EEH_Inflector::pluralize_and_lower(($model->get_this_model_name())),
241
                sprintf(
242
                    esc_html__(
243
                        // @codingStandardsIgnoreStart
244
                        'For now, only those with the admin capability to "%1$s" are allowed to use the REST API to delete data into Event Espresso.',
245
                        // @codingStandardsIgnoreEnd
246
                        'event_espresso'
247
                    ),
248
                    $default_cap_to_check_for
249
                ),
250
                array('status' => 403)
251
            );
252
        }
253
        $obj_id = $request->get_param('id');
254
        $requested_permanent_delete = filter_var($request->get_param('force'), FILTER_VALIDATE_BOOLEAN);
255
        $requested_allow_blocking = filter_var($request->get_param('allow_blocking'), FILTER_VALIDATE_BOOLEAN);