Code Duplication    Length = 14-17 lines in 2 locations

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

@@ 654-670 (lines=17) @@
651
	 *
652
	 * @return bool|WP_Error True if user successfully unlinked.
653
	 */
654
	public static function unlink_user( $data ) {
655
		$param = $data->get_json_params();
656
657
		if ( ! isset( $param['linked'] ) || $param['linked'] !== false ) {
658
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
659
		}
660
661
		if ( Jetpack::unlink_user() ) {
662
			return rest_ensure_response(
663
				array(
664
					'code' => 'success'
665
				)
666
			);
667
		}
668
669
		return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
670
	}
671
672
	/**
673
	 * Get site data, including for example, the site's current plan.
@@ 540-553 (lines=14) @@
537
	 * @since 4.3.0
538
	 * @return bool|WP_Error True if Jetpack successfully disconnected.
539
	 */
540
	public static function disconnect_site( $data ) {
541
		$param = $data->get_json_params();
542
543
		if ( ! isset( $param['isActive'] ) || $param['isActive'] !== false ) {
544
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
545
		}
546
547
		if ( Jetpack::is_active() ) {
548
			Jetpack::disconnect();
549
			return rest_ensure_response( array( 'code' => 'success' ) );
550
		}
551
552
		return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
553
	}
554
555
	/**
556
	 * Gets a new connect raw URL with fresh nonce.