Code Duplication    Length = 14-17 lines in 2 locations

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

@@ 530-543 (lines=14) @@
527
	 * @since 4.3.0
528
	 * @return bool|WP_Error True if Jetpack successfully disconnected.
529
	 */
530
	public static function disconnect_site( $data ) {
531
		$param = $data->get_json_params();
532
533
		if ( ! isset( $param['isActive'] ) || $param['isActive'] !== false ) {
534
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
535
		}
536
537
		if ( Jetpack::is_active() ) {
538
			Jetpack::disconnect();
539
			return rest_ensure_response( array( 'code' => 'success' ) );
540
		}
541
542
		return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
543
	}
544
545
	/**
546
	 * Gets a new connect raw URL with fresh nonce.
@@ 662-678 (lines=17) @@
659
	 *
660
	 * @return bool|WP_Error True if user successfully unlinked.
661
	 */
662
	public static function unlink_user( $data ) {
663
		$param = $data->get_json_params();
664
665
		if ( ! isset( $param['linked'] ) || $param['linked'] !== false ) {
666
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
667
		}
668
669
		if ( Jetpack::unlink_user() ) {
670
			return rest_ensure_response(
671
				array(
672
					'code' => 'success'
673
				)
674
			);
675
		}
676
677
		return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
678
	}
679
680
	/**
681
	 * Get site data, including for example, the site's current plan.