Code Duplication    Length = 5-7 lines in 3 locations

modules/monitor.php 1 location

@@ 93-99 (lines=7) @@
90
		) );
91
		$xml->query( 'jetpack.monitor.isUserInNotifications' );
92
93
		if ( $xml->isError() ) {
94
			if ( $die_on_error ) {
95
				wp_die( sprintf( '%s: %s', $xml->getErrorCode(), $xml->getErrorMessage() ) );
96
			} else {
97
				return new WP_Error( $xml->getErrorCode(), $xml->getErrorMessage(), array( 'status' => 400 ) );
98
			}
99
		}
100
		return $xml->getResponse();
101
	}
102

_inc/lib/class.core-rest-api-endpoints.php 1 location

@@ 918-922 (lines=5) @@
915
916
		$xml->query( 'jetpack.isSiteVerified', $args );
917
918
		if ( $xml->isError() ) {
919
			return new WP_Error( 'error_checking_if_site_verified_google', sprintf( '%s: %s', $xml->getErrorCode(), $xml->getErrorMessage() ) );
920
		} else {
921
			return $xml->getResponse();
922
		}
923
	}
924
925

packages/licensing/src/class-licensing.php 1 location

@@ 150-154 (lines=5) @@
147
148
		$xml = $this->attach_licenses_request( $licenses );
149
150
		if ( $xml->isError() ) {
151
			$error = new WP_Error( 'request_failed', __( 'License attach request failed.', 'jetpack' ) );
152
			$error->add( $xml->getErrorCode(), $xml->getErrorMessage() );
153
			return $error;
154
		}
155
156
		$results = array_map(
157
			function ( $response ) {