Code Duplication    Length = 14-17 lines in 2 locations

_inc/lib/class.core-rest-api-endpoints.php 2 locations

@@ 483-496 (lines=14) @@
480
	 * @since 4.3.0
481
	 * @return bool|WP_Error True if Jetpack successfully disconnected.
482
	 */
483
	public static function disconnect_site( $data ) {
484
		$param = $data->get_json_params();
485
486
		if ( ! isset( $param['isActive'] ) || $param['isActive'] !== false ) {
487
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
488
		}
489
490
		if ( Jetpack::is_active() ) {
491
			Jetpack::disconnect();
492
			return rest_ensure_response( array( 'code' => 'success' ) );
493
		}
494
495
		return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
496
	}
497
498
	/**
499
	 * Gets a new connect raw URL with fresh nonce.
@@ 603-619 (lines=17) @@
600
	 *
601
	 * @return bool|WP_Error True if user successfully unlinked.
602
	 */
603
	public static function unlink_user( $data ) {
604
		$param = $data->get_json_params();
605
606
		if ( ! isset( $param['linked'] ) || $param['linked'] !== false ) {
607
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
608
		}
609
610
		if ( Jetpack::unlink_user() ) {
611
			return rest_ensure_response(
612
				array(
613
					'code' => 'success'
614
				)
615
			);
616
		}
617
618
		return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
619
	}
620
621
	/**
622
	 * Get site data, including for example, the site's current plan.