Code Duplication    Length = 13-16 lines in 2 locations

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

@@ 519-531 (lines=13) @@
516
	 *
517
	 * @return bool|WP_Error True if Jetpack successfully disconnected.
518
	 */
519
	public static function disconnect_site( $request ) {
520
521
		if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) {
522
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
523
		}
524
525
		if ( Jetpack::is_active() ) {
526
			Jetpack::disconnect();
527
			return rest_ensure_response( array( 'code' => 'success' ) );
528
		}
529
530
		return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
531
	}
532
533
	/**
534
	 * Gets a new connect raw URL with fresh nonce.
@@ 639-654 (lines=16) @@
636
	 *
637
	 * @return bool|WP_Error True if user successfully unlinked.
638
	 */
639
	public static function unlink_user( $request ) {
640
641
		if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) {
642
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
643
		}
644
645
		if ( Jetpack::unlink_user() ) {
646
			return rest_ensure_response(
647
				array(
648
					'code' => 'success'
649
				)
650
			);
651
		}
652
653
		return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
654
	}
655
656
	/**
657
	 * Get site data, including for example, the site's current plan.