Code Duplication    Length = 18-18 lines in 2 locations

includes/rest-api/CMB2_REST_Controller_Fields.php 2 locations

@@ 253-270 (lines=18) @@
250
	 * @param  WP_REST_Request $request Full details about the request.
251
	 * @return WP_Error|boolean
252
	 */
253
	public function delete_item_permissions_check( $request ) {
254
		$this->initiate_rest_read_box( $request, 'field_value_delete' );
255
		if ( ! is_wp_error( $this->rest_box ) ) {
256
			$this->field = $this->rest_box->field_can_edit( $this->request->get_param( 'field_id' ), true );
257
		}
258
259
		$can_delete = current_user_can( 'delete_others_posts' );
260
261
		/**
262
		 * By default, 'delete_others_posts' is required capability.
263
		 *
264
		 * @since 2.2.3
265
		 *
266
		 * @param bool   $can_delete Whether this CMB2 endpoint can be accessed.
267
		 * @param object $controller This CMB2_REST_Controller object.
268
		 */
269
		return $this->maybe_hook_callback_and_apply_filters( 'cmb2_api_delete_field_value_permissions_check', $can_delete );
270
	}
271
272
	/**
273
	 * Delete CMB2 field value.
@@ 205-222 (lines=18) @@
202
	 * @param  WP_REST_Request $request Full details about the request.
203
	 * @return WP_Error|boolean
204
	 */
205
	public function update_item_permissions_check( $request ) {
206
		$this->initiate_rest_read_box( $request, 'field_value_update' );
207
		if ( ! is_wp_error( $this->rest_box ) ) {
208
			$this->field = $this->rest_box->field_can_edit( $this->request->get_param( 'field_id' ), true );
209
		}
210
211
		$can_update = current_user_can( 'edit_others_posts' );
212
213
		/**
214
		 * By default, 'edit_others_posts' is required capability.
215
		 *
216
		 * @since 2.2.3
217
		 *
218
		 * @param bool   $can_update Whether this CMB2 endpoint can be accessed.
219
		 * @param object $controller This CMB2_REST_Controller object.
220
		 */
221
		return $this->maybe_hook_callback_and_apply_filters( 'cmb2_api_update_field_value_permissions_check', $can_update );
222
	}
223
224
	/**
225
	 * Update CMB2 field value.