Code Duplication    Length = 13-16 lines in 2 locations

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

@@ 1370-1382 (lines=13) @@
1367
	 *
1368
	 * @return bool|WP_Error True if Jetpack successfully disconnected.
1369
	 */
1370
	public static function disconnect_site( $request ) {
1371
1372
		if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) {
1373
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
1374
		}
1375
1376
		if ( Jetpack::is_active() ) {
1377
			Jetpack::disconnect();
1378
			return rest_ensure_response( array( 'code' => 'success' ) );
1379
		}
1380
1381
		return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
1382
	}
1383
1384
	/**
1385
	 * Registers the Jetpack site
@@ 1539-1554 (lines=16) @@
1536
	 *
1537
	 * @return bool|WP_Error True if user successfully unlinked.
1538
	 */
1539
	public static function unlink_user( $request ) {
1540
1541
		if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) {
1542
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
1543
		}
1544
1545
		if ( Connection_Manager::disconnect_user() ) {
1546
			return rest_ensure_response(
1547
				array(
1548
					'code' => 'success'
1549
				)
1550
			);
1551
		}
1552
1553
		return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
1554
	}
1555
1556
	/**
1557
	 * Gets current user's tracking settings.