Code Duplication    Length = 14-17 lines in 2 locations

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

@@ 505-518 (lines=14) @@
502
	 * @since 4.3.0
503
	 * @return bool|WP_Error True if Jetpack successfully disconnected.
504
	 */
505
	public static function disconnect_site( $data ) {
506
		$param = $data->get_json_params();
507
508
		if ( ! isset( $param['isActive'] ) || $param['isActive'] !== false ) {
509
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
510
		}
511
512
		if ( Jetpack::is_active() ) {
513
			Jetpack::disconnect();
514
			return rest_ensure_response( array( 'code' => 'success' ) );
515
		}
516
517
		return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
518
	}
519
520
	/**
521
	 * Gets a new connect raw URL with fresh nonce.
@@ 625-641 (lines=17) @@
622
	 *
623
	 * @return bool|WP_Error True if user successfully unlinked.
624
	 */
625
	public static function unlink_user( $data ) {
626
		$param = $data->get_json_params();
627
628
		if ( ! isset( $param['linked'] ) || $param['linked'] !== false ) {
629
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
630
		}
631
632
		if ( Jetpack::unlink_user() ) {
633
			return rest_ensure_response(
634
				array(
635
					'code' => 'success'
636
				)
637
			);
638
		}
639
640
		return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
641
	}
642
643
	/**
644
	 * Get site data, including for example, the site's current plan.