Code Duplication    Length = 13-16 lines in 2 locations

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

@@ 1350-1362 (lines=13) @@
1347
	 *
1348
	 * @return bool|WP_Error True if Jetpack successfully disconnected.
1349
	 */
1350
	public static function disconnect_site( $request ) {
1351
1352
		if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) {
1353
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
1354
		}
1355
1356
		if ( Jetpack::is_active() ) {
1357
			Jetpack::disconnect();
1358
			return rest_ensure_response( array( 'code' => 'success' ) );
1359
		}
1360
1361
		return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
1362
	}
1363
1364
	/**
1365
	 * Registers the Jetpack site
@@ 1519-1534 (lines=16) @@
1516
	 *
1517
	 * @return bool|WP_Error True if user successfully unlinked.
1518
	 */
1519
	public static function unlink_user( $request ) {
1520
1521
		if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) {
1522
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
1523
		}
1524
1525
		if ( Connection_Manager::disconnect_user() ) {
1526
			return rest_ensure_response(
1527
				array(
1528
					'code' => 'success'
1529
				)
1530
			);
1531
		}
1532
1533
		return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
1534
	}
1535
1536
	/**
1537
	 * Gets current user's tracking settings.