Code Duplication    Length = 18-18 lines in 2 locations

includes/rest-api/CMB2_REST_Controller_Fields.php 2 locations

@@ 207-224 (lines=18) @@
204
	 * @param  WP_REST_Request $request Full details about the request.
205
	 * @return WP_Error|boolean
206
	 */
207
	public function update_item_permissions_check( $request ) {
208
		$this->initiate_rest_read_box( $request, 'field_value_update' );
209
		if ( ! is_wp_error( $this->rest_box ) ) {
210
			$this->field = $this->rest_box->field_can_edit( $this->request->get_param( 'field_id' ), true );
211
		}
212
213
		$can_update = current_user_can( 'edit_others_posts' );
214
215
		/**
216
		 * By default, 'edit_others_posts' is required capability.
217
		 *
218
		 * @since 2.2.3
219
		 *
220
		 * @param bool   $can_update Whether this CMB2 endpoint can be accessed.
221
		 * @param object $controller This CMB2_REST_Controller object.
222
		 */
223
		return $this->maybe_hook_callback_and_apply_filters( 'cmb2_api_update_field_value_permissions_check', $can_update );
224
	}
225
226
	/**
227
	 * Update CMB2 field value.
@@ 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.